We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12c96d0 commit de481bcCopy full SHA for de481bc
vm/src/protocol/iter.rs
@@ -234,11 +234,14 @@ where
234
type Item = PyResult<T>;
235
236
fn next(&mut self) -> Option<Self::Item> {
237
- let obj = PyIter::new(self.obj.borrow())
238
- .next(self.vm)
239
- .map(|iret| iret.into_result().ok())
240
- .transpose()?;
241
- Some(obj.and_then(|obj| T::try_from_object(self.vm, obj)))
+ let imp = |next: PyResult<PyIterReturn>| -> PyResult<Option<T>> {
+ let Some(obj) = next?.into_result().ok() else {
+ return Ok(None);
+ };
+ Ok(Some(T::try_from_object(self.vm, obj)?))
242
243
+ let next = PyIter::new(self.obj.borrow()).next(self.vm);
244
+ imp(next).transpose()
245
}
246
247
#[inline]
0 commit comments