pymethods: fix support for MSRV
This commit is contained in:
parent
592c98c722
commit
179b5d1f47
|
@ -695,12 +695,14 @@ struct SlotDef {
|
|||
return_mode: Option<ReturnMode>,
|
||||
}
|
||||
|
||||
const NO_ARGUMENTS: &[Ty] = &[];
|
||||
|
||||
impl SlotDef {
|
||||
const fn new(slot: &'static str, func_ty: &'static str) -> Self {
|
||||
SlotDef {
|
||||
slot: StaticIdent(slot),
|
||||
func_ty: StaticIdent(func_ty),
|
||||
arguments: &[],
|
||||
arguments: NO_ARGUMENTS,
|
||||
ret_ty: Ty::Object,
|
||||
before_call_method: None,
|
||||
extract_error_mode: ExtractErrorMode::Raise,
|
||||
|
|
|
@ -41,17 +41,6 @@ impl CompareOp {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn matches_ordering(self, ordering: std::cmp::Ordering) -> bool {
|
||||
match self {
|
||||
CompareOp::Lt => ordering.is_lt(),
|
||||
CompareOp::Le => ordering.is_le(),
|
||||
CompareOp::Eq => ordering.is_eq(),
|
||||
CompareOp::Ne => ordering.is_ne(),
|
||||
CompareOp::Gt => ordering.is_gt(),
|
||||
CompareOp::Ge => ordering.is_ge(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Basic Python class customization
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use pyo3::exceptions::PyValueError;
|
||||
use pyo3::types::{PySlice, PyType};
|
||||
use pyo3::{basic::CompareOp, exceptions::PyAttributeError, prelude::*};
|
||||
use pyo3::{exceptions::PyAttributeError, prelude::*};
|
||||
use pyo3::{ffi, py_run, AsPyPointer, PyCell};
|
||||
use std::{isize, iter};
|
||||
|
||||
|
@ -56,10 +56,6 @@ impl ExampleClass {
|
|||
i64_value as u64
|
||||
}
|
||||
|
||||
fn __richcmp__(&self, other: &Self, op: CompareOp) -> bool {
|
||||
op.matches_ordering(self.value.cmp(&other.value))
|
||||
}
|
||||
|
||||
fn __bool__(&self) -> bool {
|
||||
self.value != 0
|
||||
}
|
||||
|
@ -156,18 +152,6 @@ fn test_hash() {
|
|||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_richcmp() {
|
||||
Python::with_gil(|py| {
|
||||
let example_py = make_example(py);
|
||||
assert!(example_py
|
||||
.rich_compare(example_py, CompareOp::Eq)
|
||||
.unwrap()
|
||||
.is_true()
|
||||
.unwrap());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bool() {
|
||||
Python::with_gil(|py| {
|
||||
|
|
Loading…
Reference in New Issue