pub struct ClassicalRegister { /* private fields */ }Implementations§
Source§impl ClassicalRegister
impl ClassicalRegister
pub fn new(size: usize) -> ClassicalRegister
pub fn set(&mut self, index: usize, value: u8)
pub fn get(&self, index: usize) -> Option<u8>
pub fn size(&self) -> usize
Sourcepub fn bitstring(&self) -> String
pub fn bitstring(&self) -> String
Returns the bitstring representation of the register (e.g. “101”) Panics if any bit has not been measured.
Examples found in repository?
examples/bell_pair.rs (line 12)
3fn main() {
4 // Bell pair: H(0) -> CX(0, 1) -> Measure all
5 let mut qc = QuantumCircuit::new(2);
6 qc.h(0).cx(0, 1).measure_all();
7
8 // Single execution
9 let result = execute(&qc);
10 println!("=== Single Execution ===");
11 println!("Statevector: {:.4}", result.statevector);
12 println!("Measurement: {}", result.classical_register.bitstring());
13 println!("Time: {}", result.execution_time);
14
15 // Sampling over 1000 shots
16 let s = sample(&qc, 1000);
17 plot_histogram(&s);
18 println!("Time: {}", s.execution_time);
19}Auto Trait Implementations§
impl Freeze for ClassicalRegister
impl RefUnwindSafe for ClassicalRegister
impl Send for ClassicalRegister
impl Sync for ClassicalRegister
impl Unpin for ClassicalRegister
impl UnsafeUnpin for ClassicalRegister
impl UnwindSafe for ClassicalRegister
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more