Skip to content

Commit

Permalink
Derive Hash where possible (#8)
Browse files Browse the repository at this point in the history
* Derive Hash where possible

* Derive Eq
  • Loading branch information
aborgna-q authored Jul 21, 2023
1 parent 27da316 commit 619db15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/circuit_json.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::optype::OpType;
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Register(pub String, pub Vec<i64>);

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
Expand All @@ -12,13 +12,13 @@ pub struct CompositeGate {
name: String,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct BitRegister {
name: String,
size: u32,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
#[serde(untagged)]
pub enum ClassicalExpUnit {
U32(u32),
Expand All @@ -27,19 +27,19 @@ pub enum ClassicalExpUnit {
ClassicalExpUnit(ClassicalExp),
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct ClassicalExp {
args: Vec<ClassicalExpUnit>,
op: String,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct PauliStabiliser {
coeff: bool,
string: Vec<String>,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct BoxID(uuid::Uuid);

/// Box for an operation, the enum variant names come from the names
Expand Down Expand Up @@ -144,7 +144,7 @@ pub struct Command<P = String> {
pub opgroup: Option<String>,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Permutation(pub Register, pub Register);

/// Pytket canonical circuit
Expand Down
2 changes: 1 addition & 1 deletion src/optype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pyo3::{exceptions::PyNotImplementedError, pyclass::CompareOp};
use serde::{Deserialize, Serialize};

#[cfg_attr(feature = "pyo3", pyclass(name = "RsOpType"))]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]
pub enum OpType {
/**
* Quantum input node of the circuit
Expand Down

0 comments on commit 619db15

Please sign in to comment.