Fix impl FromPyObject for Py<T>
This commit is contained in:
parent
9a141fb921
commit
d6035bce15
|
@ -1,6 +1,10 @@
|
|||
Changes
|
||||
-------
|
||||
|
||||
0.2.4 (2018-01-xx)
|
||||
|
||||
* Fix impl `FromPyObject` for `Py<T>`
|
||||
|
||||
* Mark method that work with raw pointers as unsafe #95
|
||||
|
||||
|
||||
|
|
|
@ -328,13 +328,14 @@ impl<'a, T> std::convert::From<&'a mut T> for PyObject
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, T> FromPyObject<'a> for Py<T> where T: ToPyPointer + FromPyObject<'a>
|
||||
impl<'a, T> FromPyObject<'a> for Py<T>
|
||||
where T: ToPyPointer, &'a T: 'a + FromPyObject<'a>
|
||||
{
|
||||
/// Extracts `Self` from the source `PyObject`.
|
||||
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
|
||||
{
|
||||
unsafe {
|
||||
ob.extract::<T>().map(|val| Py::from_borrowed_ptr(val.as_ptr()))
|
||||
ob.extract::<&T>().map(|val| Py::from_borrowed_ptr(val.as_ptr()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue