quil_rs/instruction/
reset.rs1#[cfg(feature = "stubs")]
2use pyo3_stub_gen::derive::gen_stub_pyclass;
3
4use crate::{pickleable_new, quil::Quil};
5
6use super::Qubit;
7
8#[derive(Clone, Debug, PartialEq, Eq, Hash)]
9#[cfg_attr(feature = "stubs", gen_stub_pyclass)]
10#[cfg_attr(
11 feature = "python",
12 pyo3::pyclass(module = "quil.instructions", eq, frozen, hash, get_all, subclass)
13)]
14pub struct Reset {
15 pub qubit: Option<Qubit>,
16}
17
18pickleable_new! {
19 impl Reset {
20 pub fn new(qubit: Option<Qubit>);
21 }
22}
23
24impl Quil for Reset {
25 fn write(
26 &self,
27 writer: &mut impl std::fmt::Write,
28 fall_back_to_debug: bool,
29 ) -> crate::quil::ToQuilResult<()> {
30 match &self.qubit {
31 Some(qubit) => {
32 write!(writer, "RESET ")?;
33 qubit.write(writer, fall_back_to_debug)
34 }
35 None => write!(writer, "RESET").map_err(Into::into),
36 }
37 }
38}