From c5e03805f26971640757f92e1ae25124d062a4de Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Tue, 9 Jul 2024 13:08:43 +0100 Subject: [PATCH] Weaken bounds on `Operation: Default` --- src/circuit_json.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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, } -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 { +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() + } + } +}