Skip to content

Commit

Permalink
Add: iter() method to CircuitData
Browse files Browse the repository at this point in the history
- Make `PackedInstruction` public.
  • Loading branch information
raynelfss committed Jul 11, 2024
1 parent d86f995 commit 1c2a7c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,4 +1167,9 @@ impl CircuitData {
py_op: RefCell::new(inst.py_op.clone()),
})
}
}

/// Rust native method, returns an iterator over all the instructions present in the circuit.
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &PackedInstruction> + 'a {
self.data.iter()
}
}
2 changes: 1 addition & 1 deletion crates/circuit/src/circuit_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct ExtraInstructionAttributes {

/// Private type used to store instructions with interned arg lists.
#[derive(Clone, Debug)]
pub(crate) struct PackedInstruction {
pub struct PackedInstruction {
/// The Python-side operation instance.
pub op: OperationType,
/// The index under which the interner has stored `qubits`.
Expand Down

0 comments on commit 1c2a7c2

Please sign in to comment.