pub trait PyTryInto<T>: Sized {
    // Required methods
    fn try_into(&self) -> Result<&T, PyDowncastError<'_>>;
    fn try_into_exact(&self) -> Result<&T, PyDowncastError<'_>>;
}
👎Deprecated since 0.21.0
Expand description

Trait implemented by Python object types that allow a checked downcast. This trait is similar to std::convert::TryInto

Required Methods§

source

fn try_into(&self) -> Result<&T, PyDowncastError<'_>>

👎Deprecated since 0.21.0: use value.downcast() instead of value.try_into()

Cast from PyObject to a concrete Python object type.

source

fn try_into_exact(&self) -> Result<&T, PyDowncastError<'_>>

👎Deprecated since 0.21.0: use value.downcast() instead of value.try_into_exact()

Cast from PyObject to a concrete Python object type. With exact type check.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<U> PyTryInto<U> for PyAny
where U: for<'v> PyTryFrom<'v>,

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