We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d4084fb commit e1f02fcCopy full SHA for e1f02fc
ast/src/pyo3.rs
@@ -38,11 +38,11 @@ impl<T: ToPyo3Ast> ToPyo3Ast for Option<T> {
38
39
impl<T: ToPyo3Ast> ToPyo3Ast for Vec<T> {
40
fn to_pyo3_ast(&self, py: Python) -> PyResult<Py<PyAny>> {
41
- let list = PyList::empty(py);
42
- for item in self {
43
- let py_item = item.to_pyo3_ast(py)?;
44
- list.append(py_item)?;
45
- }
+ let elts = self
+ .iter()
+ .map(|item| item.to_pyo3_ast(py))
+ .collect::<Result<Vec<_>, _>>()?;
+ let list = PyList::new(py, elts);
46
Ok(list.into())
47
}
48
0 commit comments