quil_rs/instruction/
reset.rs

1use crate::quil::Quil;
2
3use super::Qubit;
4
5#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6pub struct Reset {
7    pub qubit: Option<Qubit>,
8}
9
10impl Reset {
11    pub fn new(qubit: Option<Qubit>) -> Self {
12        Self { qubit }
13    }
14}
15
16impl Quil for Reset {
17    fn write(
18        &self,
19        writer: &mut impl std::fmt::Write,
20        fall_back_to_debug: bool,
21    ) -> crate::quil::ToQuilResult<()> {
22        match &self.qubit {
23            Some(qubit) => {
24                write!(writer, "RESET ")?;
25                qubit.write(writer, fall_back_to_debug)
26            }
27            None => write!(writer, "RESET").map_err(Into::into),
28        }
29    }
30}