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 bool to a Python bool.

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.

Implementors