qcs_api_client_common/py/
mod.rs1#[macro_export]
6macro_rules! impl_repr {
7 ($name: ident) => {
8 #[pyo3::pymethods]
9 impl $name {
10 #[must_use]
11 fn __repr__(&self) -> String {
12 format!("{:?}", self)
13 }
14 }
15 };
16}
17
18#[macro_export]
20macro_rules! impl_str {
21 ($name: ident) => {
22 #[$crate::pyo3::pymethods]
23 impl $name {
24 fn __str__(&self) -> String {
25 format!("{}", $crate::PyWrapper::as_inner(self))
26 }
27 }
28 };
29}
30
31#[macro_export]
35macro_rules! impl_eq {
36 ($name: ident) => {
37 #[pymethods]
38 impl $name {
39 fn __richcmp__(
40 &self,
41 py: pyo3::Python<'_>,
42 other: &Self,
43 op: pyo3::pyclass::CompareOp,
44 ) -> pyo3::PyObject {
45 use pyo3::IntoPy;
46 match op {
47 pyo3::pyclass::CompareOp::Eq => (self == other).into_py(py),
48 pyo3::pyclass::CompareOp::Ne => (self != other).into_py(py),
49 _ => py.NotImplemented(),
50 }
51 }
52 }
53 };
54}