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

Method downcast_ref

crates/vm/src/object/core.rs:1508–1516  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

1506 /// Attempt to downcast this reference to a subclass.
1507 #[inline(always)]
1508 pub fn downcast_ref<T: PyPayload>(&self) -> Option<&Py<T>> {
1509 if self.downcastable::<T>() {
1510 // SAFETY: just checked that the payload is T, and PyRef is repr(transparent) over
1511 // PyObjectRef
1512 Some(unsafe { self.downcast_unchecked_ref::<T>() })
1513 } else {
1514 None
1515 }
1516 }
1517
1518 #[inline(always)]
1519 pub fn downcast_ref_if_exact<T: PyPayload>(&self, vm: &VirtualMachine) -> Option<&Py<T>> {

Callers 15

remove_done_callbackMethod · 0.80
as_interned_strMethod · 0.80
newMethod · 0.80
call_native_decode_errorFunction · 0.80
getMethod · 0.80
slot_delMethod · 0.80
slot_callMethod · 0.80
slot_hashMethod · 0.80
slot_reprMethod · 0.80
slot_richcompareMethod · 0.80
slot_getattroMethod · 0.80
slot_as_bufferMethod · 0.80

Calls 1

SomeClass · 0.50

Tested by

no test coverage detected