Trait pyo3::conversion::AsPyPointer[][src]

pub trait AsPyPointer {
    fn as_ptr(&self) -> *mut PyObject;
}
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.

Example

use pyo3::{AsPyPointer, prelude::*};
let gil = Python::acquire_gil();
let dict = pyo3::types::PyDict::new(gil.python());
// All native object wrappers implement AsPyPointer!!!
assert_ne!(dict.as_ptr(), std::ptr::null_mut());

Required methods

Retrieves the underlying FFI pointer (as a borrowed pointer).

Implementations on Foreign Types

Convert None into a null pointer.

Implementors