Trait pyo3::conversion::AsPyPointer
source · [−]Expand description
This trait represents that we can do zero-cost conversion from the object to a FFI pointer.
This trait is implemented for types that internally wrap a pointer to a Python object.
Examples
use pyo3::{prelude::*, AsPyPointer};
Python::with_gil(|py| {
let dict = pyo3::types::PyDict::new(py);
// All native object wrappers implement AsPyPointer!!!
assert_ne!(dict.as_ptr(), std::ptr::null_mut());
});
Required Methods
Implementations on Foreign Types
sourceimpl<T> AsPyPointer for Option<T> where
T: AsPyPointer,
impl<T> AsPyPointer for Option<T> where
T: AsPyPointer,
Convert None
into a null pointer.