Skip to content

Commit

Permalink
Make CircuitData inner data accessible in Rust (Qiskit#12766)
Browse files Browse the repository at this point in the history
* Add: `iter()` method to `CircuitData`
- Make `PackedInstruction` public.

* Docs: Remove "rust-native method" from docstring.
  • Loading branch information
raynelfss authored Jul 12, 2024
1 parent 59a62d9 commit 2a2b806
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions 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()),
})
}

/// Returns an iterator over all the instructions present in the circuit.
pub fn iter(&self) -> impl Iterator<Item = &PackedInstruction> {
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 2a2b806

Please sign in to comment.