diff --git a/src/circuit_json.rs b/src/circuit_json.rs index fba9889..35b48fb 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -138,7 +138,7 @@ pub enum Classical { } /// Serializable operation descriptor. -#[derive(Deserialize, Serialize, Clone, Debug, Default, PartialEq)] +#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] #[non_exhaustive] pub struct Operation
{ /// The type of operation. @@ -202,14 +202,10 @@ pub struct SerialCircuit
{
pub implicit_permutation: Vec Operation {
- /// Returns a default-initialized Operation with the given type.
- ///
- /// For optypes that require additional parameters, this may generate
- /// invalid operations.
- pub fn from_optype(op_type: OpType) -> Self {
+impl Default for Operation {
+ fn default() -> Self {
Self {
- op_type,
+ op_type: Default::default(),
n_qb: None,
data: None,
params: None,
@@ -220,3 +216,16 @@ impl Operation {
}
}
}
+
+impl Operation {
+ /// Returns a default-initialized Operation with the given type.
+ ///
+ /// For optypes that require additional parameters, this may generate
+ /// invalid operations.
+ pub fn from_optype(op_type: OpType) -> Self {
+ Self {
+ op_type,
+ ..Operation::default()
+ }
+ }
+}