Merge branch 'master' of github.com:PyO3/pyo3

This commit is contained in:
Nikolay Kim 2017-07-31 10:43:23 -07:00
commit 95915b55dd
1 changed files with 6 additions and 6 deletions

View File

@ -237,10 +237,10 @@ impl <'source, T> FromPyObject<'source> for Vec<T>
fn extract_sequence<'s, T>(obj: &'s PyObjectRef) -> PyResult<Vec<T>> where T: FromPyObject<'s> fn extract_sequence<'s, T>(obj: &'s PyObjectRef) -> PyResult<Vec<T>> where T: FromPyObject<'s>
{ {
let seq = PySequence::try_from(obj)?; let seq = PySequence::try_from(obj)?;
let mut v = Vec::new(); let mut v = Vec::with_capacity(seq.len().unwrap_or(0) as usize);
for item in try!(seq.iter()) { for item in seq.iter()? {
let item = try!(item); let item = try!(item);
v.push(try!(item.extract::<T>())); v.push(item.extract::<T>()?);
} }
Ok(v) Ok(v)
} }