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

Method into_exact_or

crates/vm/src/object/ext.rs:122–132  ·  view source on GitHub ↗
(
        self,
        ctx: &Context,
        f: impl FnOnce(Self) -> PyRefExact<T>,
    )

Source from the content-addressed store, hash-verified

120
121impl<T: PyPayload> PyRef<T> {
122 pub fn into_exact_or(
123 self,
124 ctx: &Context,
125 f: impl FnOnce(Self) -> PyRefExact<T>,
126 ) -> PyRefExact<T> {
127 if self.class().is(T::class(ctx)) {
128 unsafe { PyRefExact::new_unchecked(self) }
129 } else {
130 f(self)
131 }
132 }
133}
134
135/// PyRef but guaranteed not to be a subtype instance

Callers 1

__int__Method · 0.80

Calls 3

isMethod · 0.80
fFunction · 0.50
classMethod · 0.45

Tested by

no test coverage detected