(&self)
| 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>> { |
no test coverage detected