diff --git a/src/conversion.rs b/src/conversion.rs index bf3e7543..cfcd0f84 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -89,7 +89,7 @@ pub trait ToPyObject<'p> { /// /// In cases where the result does not depend on the `'prepared` lifetime, /// the inherent method `PyObject::extract()` can be used. -pub trait ExtractPyObject<'python, 'source, 'prepared> { +pub trait ExtractPyObject<'python, 'source, 'prepared> : Sized { type Prepared; fn prepare_extract(obj: &'source PyObject<'python>) -> PyResult<'python, Self::Prepared>; @@ -97,8 +97,10 @@ pub trait ExtractPyObject<'python, 'source, 'prepared> { fn extract(prepared: &'prepared Self::Prepared) -> PyResult<'python, Self>; } -impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> - for T where T: PythonObjectWithCheckedDowncast<'python> { +impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> for T +where T: PythonObjectWithCheckedDowncast<'python>, + 'python: 'source +{ type Prepared = &'source PyObject<'python>; @@ -108,7 +110,7 @@ impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepare } #[inline] - fn extract(&&ref obj: &'prepared Self::Prepared) -> PyResult<'python, T> { + fn extract(&obj: &'prepared &'source PyObject<'python>) -> PyResult<'python, T> { Ok(try!(obj.clone().cast_into())) } } diff --git a/src/objects/list.rs b/src/objects/list.rs index 07e3182c..df272a68 100644 --- a/src/objects/list.rs +++ b/src/objects/list.rs @@ -137,7 +137,10 @@ impl <'p, T> ToPyObject<'p> for [T] where T: ToPyObject<'p> { } impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> - for Vec where T: for<'s, 'p> ExtractPyObject<'python, 's, 'p> { + for Vec + where T: for<'s, 'p> ExtractPyObject<'python, 's, 'p>, + 'python : 'source +{ type Prepared = &'source PyObject<'python>; @@ -147,7 +150,7 @@ impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepare } #[inline] - fn extract(&&ref obj: &'prepared Self::Prepared) -> PyResult<'python, Vec> { + fn extract(&obj: &'prepared &'source PyObject<'python>) -> PyResult<'python, Vec> { let list = try!(obj.cast_as::()); let mut v = Vec::with_capacity(list.len()); for i in 0 .. list.len() { diff --git a/src/objects/mod.rs b/src/objects/mod.rs index e2c6d2da..bffe7b06 100644 --- a/src/objects/mod.rs +++ b/src/objects/mod.rs @@ -156,6 +156,7 @@ macro_rules! extract( impl <'python, 'source, 'prepared> ::conversion::ExtractPyObject<'python, 'source, 'prepared> for $t + where 'python: 'source { type Prepared = &'source PyObject<'python>; diff --git a/src/objects/num.rs b/src/objects/num.rs index c3e624fc..78fcd2f8 100644 --- a/src/objects/num.rs +++ b/src/objects/num.rs @@ -197,6 +197,7 @@ macro_rules! int_convert_u64_or_i64 ( impl <'python, 'source, 'prepared> ExtractPyObject<'python, 'source, 'prepared> for $rust_type + where 'python: 'source { type Prepared = &'source PyObject<'python>;