(this: PyRefMut<Self>)
| 43 | #[pyproto] |
| 44 | impl PyIterProtocol for PyMap { |
| 45 | fn __iter__(this: PyRefMut<Self>) -> PyResult<super::iterator::PyObjectPairIterator> { |
| 46 | let gil = Python::acquire_gil(); |
| 47 | let py = gil.python(); |
| 48 | |
| 49 | let mut elements = std::vec::Vec::new(); |
| 50 | for pair in this.as_ref().iter() { |
| 51 | elements.push(( |
| 52 | pair.key().to_object(py), |
| 53 | from_data(py, &pair.value().clone())?, |
| 54 | )); |
| 55 | } |
| 56 | |
| 57 | Ok(super::iterator::PyObjectPairIterator::new( |
| 58 | elements.into_iter(), |
| 59 | )) |
| 60 | } |
| 61 | } |