Skip to main content

extract_receiver_trusted

Function extract_receiver_trusted 

Source
pub unsafe fn extract_receiver_trusted<'a, 'py, T, R>(
    bound_ref: &'a Bound<'py, PyAny>,
) -> PyResult<R>
where T: PyTypeCheck + 'a, R: TryFrom<&'a Bound<'py, T>>, R::Error: Into<PyErr>,
Expand description

Fused extraction for receivers which implement TryFrom<&Bound<T>> (e.g. Py<T>, Bound<T>, PyRef<T>), used to keep the generated code small. Trusted variant: performs an unchecked cast for extension-type slot receivers where CPython guarantees the receiver type.

§Safety

The caller must ensure that bound_ref is an instance of T. This invariant is upheld by CPython when dispatching through type slots.

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here