(self)
| 2242 | } |
| 2243 | #[inline] |
| 2244 | pub fn upcast<U: PyPayload + StaticType>(self) -> PyRef<U> |
| 2245 | where |
| 2246 | T: StaticType, |
| 2247 | { |
| 2248 | debug_assert!(T::static_type().is_subtype(U::static_type())); |
| 2249 | let obj: PyObjectRef = self.into(); |
| 2250 | match obj.downcast::<U>() { |
| 2251 | Ok(upcast_ref) => upcast_ref, |
| 2252 | Err(_) => unsafe { core::hint::unreachable_unchecked() }, |
| 2253 | } |
| 2254 | } |
| 2255 | } |
| 2256 | |
| 2257 | impl<T: crate::class::PySubclass> Py<T> { |
no outgoing calls
no test coverage detected