Skip to content

Simplify FromPyPointer #781

@davidhewitt

Description

@davidhewitt

There are so many methods in this trait. Is there a reason why we don't just have

unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut ffi::PyObject) -> PyResult<&'p Self>;
unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut ffi::PyObject) -> PyResult<&'p Self>;

As the only trait method. And then just let users choose if they want to .ok(), .unwrap(), or .expect() this, instead of all the _or_opt, _or_panic etc.

Originally posted by @davidhewitt in #770

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions