Constructs a PyIterator from a Python iterator object.
(
py: Python<'p>,
obj: PyObject,
)
| 34 | impl<'p> PyIterator<'p> { |
| 35 | /// Constructs a PyIterator from a Python iterator object. |
| 36 | pub fn from_object( |
| 37 | py: Python<'p>, |
| 38 | obj: PyObject, |
| 39 | ) -> Result<PyIterator<'p>, PythonObjectDowncastError<'p>> { |
| 40 | if unsafe { ffi::PyIter_Check(obj.as_ptr()) != 0 } { |
| 41 | Ok(PyIterator { py, iter: obj }) |
| 42 | } else { |
| 43 | Err(PythonObjectDowncastError::new( |
| 44 | py, |
| 45 | "PyIterator", |
| 46 | obj.get_type(py), |
| 47 | )) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /// Gets the Python iterator object. |
| 52 | #[inline] |
nothing calls this directly
no test coverage detected