Skip to content

Required trait bounds for a generic function using FromPyObject::extract? #3058

Answered by mejrs
AntoineRR asked this question in Questions
Discussion options

You must be logged in to vote

Try using

pub fn from_py_generic<T: for <'a> FromPyObject<'a>>(obj: Py<PyAny>) -> PyResult<T> {
    Python::with_gil(|py| obj.extract(py))
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AntoineRR
Comment options

Answer selected by AntoineRR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants