Fix some build errors

This commit is contained in:
Daniel Grunwald 2015-08-20 21:14:28 +02:00
parent 814a2ac720
commit 6316ddc28b
4 changed files with 13 additions and 6 deletions

View File

@ -89,7 +89,7 @@ pub trait ToPyObject<'p> {
/// ///
/// In cases where the result does not depend on the `'prepared` lifetime, /// In cases where the result does not depend on the `'prepared` lifetime,
/// the inherent method `PyObject::extract()` can be used. /// the inherent method `PyObject::extract()` can be used.
pub trait ExtractPyObject<'python, 'source, 'prepared> { pub trait ExtractPyObject<'python, 'source, 'prepared> : Sized {
type Prepared; type Prepared;
fn prepare_extract(obj: &'source PyObject<'python>) -> PyResult<'python, Self::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>; fn extract(prepared: &'prepared Self::Prepared) -> PyResult<'python, Self>;
} }
impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> for T
for T where T: PythonObjectWithCheckedDowncast<'python> { where T: PythonObjectWithCheckedDowncast<'python>,
'python: 'source
{
type Prepared = &'source PyObject<'python>; type Prepared = &'source PyObject<'python>;
@ -108,7 +110,7 @@ impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepare
} }
#[inline] #[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())) Ok(try!(obj.clone().cast_into()))
} }
} }

View File

@ -137,7 +137,10 @@ impl <'p, T> ToPyObject<'p> for [T] where T: ToPyObject<'p> {
} }
impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared> impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepared>
for Vec<T> where T: for<'s, 'p> ExtractPyObject<'python, 's, 'p> { for Vec<T>
where T: for<'s, 'p> ExtractPyObject<'python, 's, 'p>,
'python : 'source
{
type Prepared = &'source PyObject<'python>; type Prepared = &'source PyObject<'python>;
@ -147,7 +150,7 @@ impl <'python, 'source, 'prepared, T> ExtractPyObject<'python, 'source, 'prepare
} }
#[inline] #[inline]
fn extract(&&ref obj: &'prepared Self::Prepared) -> PyResult<'python, Vec<T>> { fn extract(&obj: &'prepared &'source PyObject<'python>) -> PyResult<'python, Vec<T>> {
let list = try!(obj.cast_as::<PyList>()); let list = try!(obj.cast_as::<PyList>());
let mut v = Vec::with_capacity(list.len()); let mut v = Vec::with_capacity(list.len());
for i in 0 .. list.len() { for i in 0 .. list.len() {

View File

@ -156,6 +156,7 @@ macro_rules! extract(
impl <'python, 'source, 'prepared> impl <'python, 'source, 'prepared>
::conversion::ExtractPyObject<'python, 'source, 'prepared> ::conversion::ExtractPyObject<'python, 'source, 'prepared>
for $t for $t
where 'python: 'source
{ {
type Prepared = &'source PyObject<'python>; type Prepared = &'source PyObject<'python>;

View File

@ -197,6 +197,7 @@ macro_rules! int_convert_u64_or_i64 (
impl <'python, 'source, 'prepared> impl <'python, 'source, 'prepared>
ExtractPyObject<'python, 'source, 'prepared> for $rust_type ExtractPyObject<'python, 'source, 'prepared> for $rust_type
where 'python: 'source
{ {
type Prepared = &'source PyObject<'python>; type Prepared = &'source PyObject<'python>;