MCPcopy Index your code
hub / github.com/RustPython/RustPython / cmp

Method cmp

crates/vm/src/builtins/weakref.rs:120–135  ·  view source on GitHub ↗
(
        zelf: &Py<Self>,
        other: &PyObject,
        op: PyComparisonOp,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

118
119impl Comparable for PyWeak {
120 fn cmp(
121 zelf: &Py<Self>,
122 other: &PyObject,
123 op: PyComparisonOp,
124 vm: &VirtualMachine,
125 ) -> PyResult<crate::function::PyComparisonValue> {
126 op.eq_only(|| {
127 let other = class_or_notimplemented!(Self, other);
128 let both = zelf.upgrade().and_then(|s| other.upgrade().map(|o| (s, o)));
129 let eq = match both {
130 Some((a, b)) => vm.bool_eq(&a, &b)?,
131 None => zelf.is(other),
132 };
133 Ok(eq.into())
134 })
135 }
136}
137
138impl Representable for PyWeak {

Callers

nothing calls this directly

Calls 5

eq_onlyMethod · 0.80
bool_eqMethod · 0.80
isMethod · 0.80
upgradeMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected