Expand description
A commonly-used alias for Py<PyAny>
.
This is an owned reference a Python object without any type information. This value can also be safely sent between threads.
See the documentation for Py
.
Implementations§
source§impl PyObject
impl PyObject
sourcepub fn downcast<'p, T>(
&'p self,
py: Python<'p>
) -> Result<&T, PyDowncastError<'_>>where
T: PyTryFrom<'p>,
pub fn downcast<'p, T>(
&'p self,
py: Python<'p>
) -> Result<&T, PyDowncastError<'_>>where
T: PyTryFrom<'p>,
Casts the PyObject to a concrete Python object type.
This can cast only to native Python types, not types implemented in Rust. For a more
flexible alternative, see Py::extract
.
sourcepub unsafe fn downcast_unchecked<'p, T>(&'p self, py: Python<'p>) -> &Twhere
T: PyTryFrom<'p>,
pub unsafe fn downcast_unchecked<'p, T>(&'p self, py: Python<'p>) -> &Twhere
T: PyTryFrom<'p>,
Casts the PyObject to a concrete Python object type without checking validity.
This can cast only to native Python types, not types implemented in Rust. For a more
flexible alternative, see Py::extract
.
Safety
Callers must ensure that the type is valid or risk type confusion.