We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4084fb commit c484194Copy full SHA for c484194
ast/src/pyo3.rs
@@ -38,11 +38,8 @@ 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