pub trait ToPyObject {
    fn to_object(&self, py: Python<'_>) -> PyObject;
}
Expand description

Conversion trait that allows various objects to be converted into PyObject.

Required Methods

Converts self into a Python object.

Implementations on Foreign Types

Identity conversion: allows using existing PyObject instances where T: ToPyObject is expected.

Option::Some<T> is converted like T. Option::None is converted to Python None.

() is converted to Python None.

Converts a Rust str to a Python object. See PyString::new for details on the conversion.

Converts a Rust Cow<'_, str> to a Python object. See PyString::new for details on the conversion.

Converts a Rust String to a Python object. See PyString::new for details on the conversion.

Converts a Rust bool to a Python bool.

Implementors