Skip to content

Commit

Permalink
fix Result repr
Browse files Browse the repository at this point in the history
  • Loading branch information
sezna committed Aug 27, 2024
1 parent ca6bb9e commit 79edd1b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pip/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use miette::{Diagnostic, Report};
use num_bigint::BigUint;
use num_complex::Complex64;
use pyo3::{
basic::CompareOp,
create_exception,
exceptions::PyException,
prelude::*,
Expand Down Expand Up @@ -422,6 +423,27 @@ pub(crate) enum Result {
One,
}

#[pymethods]
impl Result {
fn __repr__(&self) -> String {
match self {
Result::Zero => "Zero".to_owned(),
Result::One => "One".to_owned(),
}
}

fn __str__(&self) -> String {
self.__repr__()
}

fn __hash__(&self) -> u32 {
match self {
Result::Zero => 0,
Result::One => 1,
}
}
}

#[derive(PartialEq)]
#[pyclass(unsendable, eq, eq_int)]
/// A Q# Pauli operator.
Expand Down

0 comments on commit 79edd1b

Please sign in to comment.