(self, vm: &VirtualMachine)
| 1299 | /// another downcast can be attempted without unnecessary cloning. |
| 1300 | #[inline] |
| 1301 | pub fn downcast_exact<T: PyPayload>(self, vm: &VirtualMachine) -> Result<PyRefExact<T>, Self> { |
| 1302 | if self.class().is(T::class(&vm.ctx)) { |
| 1303 | // TODO: is this always true? |
| 1304 | assert!( |
| 1305 | self.downcastable::<T>(), |
| 1306 | "obj.__class__ is T::class() but payload is not T" |
| 1307 | ); |
| 1308 | // SAFETY: just asserted that downcastable::<T>() |
| 1309 | Ok(unsafe { PyRefExact::new_unchecked(PyRef::from_obj_unchecked(self)) }) |
| 1310 | } else { |
| 1311 | Err(self) |
| 1312 | } |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | impl PyObject { |
no test coverage detected