quil/instruction/
qubit.rs1use quil_rs::instruction::{Qubit, QubitPlaceholder};
2
3use rigetti_pyo3::{
4 impl_compare, impl_hash, impl_repr, py_wrap_type, py_wrap_union_enum,
5 pyo3::{
6 pymethods,
7 types::{PyLong, PyString},
8 Py,
9 },
10};
11
12use crate::{impl_eq, impl_to_quil};
13
14py_wrap_union_enum! {
15 #[derive(Debug, Eq, Hash, PartialEq)]
16 #[pyo3(subclass, module = "quil.instructions")]
17 PyQubit(Qubit) as "Qubit" {
18 fixed: Fixed => Py<PyLong>,
19 variable: Variable => Py<PyString>,
20 placeholder: Placeholder => PyQubitPlaceholder
21 }
22}
23impl_repr!(PyQubit);
24impl_to_quil!(PyQubit);
25impl_hash!(PyQubit);
26impl_eq!(PyQubit);
27
28py_wrap_type! {
29 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
30 #[pyo3(subclass, module = "quil.instructions")]
31 PyQubitPlaceholder(QubitPlaceholder) as "QubitPlaceholder"
32}
33impl_repr!(PyQubitPlaceholder);
34impl_hash!(PyQubitPlaceholder);
35impl_compare!(PyQubitPlaceholder);
36
37#[pymethods]
38impl PyQubitPlaceholder {
39 #[new]
40 fn new() -> Self {
41 Self(QubitPlaceholder::default())
42 }
43}