Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions quil-rs/src/instruction/calibration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub trait CalibrationSignature {
fn has_signature(&self, signature: &Self::Signature<'_>) -> bool;
}

#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Calibration {
pub instructions: Vec<Instruction>,
pub modifiers: Vec<GateModifier>,
Expand Down Expand Up @@ -86,7 +86,7 @@ impl CalibrationSignature for Calibration {
}
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MeasureCalibrationDefinition {
pub qubit: Option<Qubit>,
pub parameter: String,
Expand Down
2 changes: 1 addition & 1 deletion quil-rs/src/instruction/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::quil::Quil;

use super::Instruction;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct CircuitDefinition {
pub name: String,
pub parameters: Vec<String>,
Expand Down
12 changes: 8 additions & 4 deletions quil-rs/src/instruction/classical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{hash::hash_f64, quil::Quil};

use super::MemoryReference;

#[derive(Clone, Debug, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Arithmetic {
pub operator: ArithmeticOperator,
pub destination: ArithmeticOperand,
Expand Down Expand Up @@ -44,6 +44,8 @@ pub enum ArithmeticOperand {
MemoryReference(MemoryReference),
}

impl std::cmp::Eq for ArithmeticOperand {}

impl std::hash::Hash for ArithmeticOperand {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
match self {
Expand Down Expand Up @@ -191,7 +193,7 @@ impl Quil for Convert {
}
}

#[derive(Clone, Debug, Hash, PartialEq)]
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Move {
pub destination: MemoryReference,
pub source: ArithmeticOperand,
Expand Down Expand Up @@ -220,7 +222,7 @@ impl Quil for Move {
}
}

#[derive(Clone, Debug, Hash, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Exchange {
pub left: MemoryReference,
pub right: MemoryReference,
Expand All @@ -246,7 +248,7 @@ impl Exchange {
}
}

#[derive(Clone, Debug, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Comparison {
pub operator: ComparisonOperator,
pub operands: (MemoryReference, MemoryReference, ComparisonOperand),
Expand Down Expand Up @@ -285,6 +287,8 @@ pub enum ComparisonOperand {
MemoryReference(MemoryReference),
}

impl std::cmp::Eq for ComparisonOperand {}

impl Quil for ComparisonOperand {
fn write(
&self,
Expand Down
6 changes: 3 additions & 3 deletions quil-rs/src/instruction/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl PartialEq for TargetPlaceholder {
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Jump {
pub target: Target,
}
Expand All @@ -131,7 +131,7 @@ impl Jump {
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct JumpWhen {
pub target: Target,
pub condition: MemoryReference,
Expand All @@ -156,7 +156,7 @@ impl Quil for JumpWhen {
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct JumpUnless {
pub target: Target,
pub condition: MemoryReference,
Expand Down
2 changes: 1 addition & 1 deletion quil-rs/src/instruction/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl Quil for Load {
}
}

#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Store {
pub destination: String,
pub offset: MemoryReference,
Expand Down
14 changes: 12 additions & 2 deletions quil-rs/src/instruction/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ impl FrameDefinition {
}
}

impl std::hash::Hash for FrameDefinition {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.identifier.hash(state);
for (k, v) in &self.attributes {
k.hash(state);
v.hash(state);
}
}
}

impl Quil for FrameDefinition {
fn write(
&self,
Expand Down Expand Up @@ -104,7 +114,7 @@ impl FromStr for FrameIdentifier {
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Capture {
pub blocking: bool,
pub frame: FrameIdentifier,
Expand Down Expand Up @@ -151,7 +161,7 @@ impl Quil for Capture {
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Pulse {
pub blocking: bool,
pub frame: FrameIdentifier,
Expand Down
2 changes: 1 addition & 1 deletion quil-rs/src/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub enum ValidationError {
GateError(#[from] GateError),
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Instruction {
Arithmetic(Arithmetic),
BinaryLogic(BinaryLogic),
Expand Down
10 changes: 10 additions & 0 deletions quil-rs/src/instruction/waveform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ impl WaveformInvocation {
}
}

impl std::hash::Hash for WaveformInvocation {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.name.hash(state);
for (k, v) in &self.parameters {
k.hash(state);
v.hash(state);
}
}
}

impl Quil for WaveformInvocation {
fn write(
&self,
Expand Down