Skip to content

Commit f2bb202

Browse files
committed
refactor: updated zip nth() to iterator nth()
When the iterator nth() method was updated it was not in zip. Zip needs to implement nth() for the trusted length specialised implementation.
1 parent 0597339 commit f2bb202

File tree

1 file changed

+3
-8
lines changed
  • library/core/src/iter/adapters

1 file changed

+3
-8
lines changed

library/core/src/iter/adapters/zip.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ where
2727
ZipNew::new(a, b)
2828
}
2929

30-
fn super_nth(&mut self, mut n: usize) -> Option<(A::Item, B::Item)> {
31-
while let Some(x) = Iterator::next(self) {
32-
if n == 0 {
33-
return Some(x);
34-
}
35-
n -= 1;
36-
}
37-
None
30+
fn super_nth(&mut self, n: usize) -> Option<(A::Item, B::Item)> {
31+
self.advance_by(n).ok()?;
32+
self.next()
3833
}
3934
}
4035

0 commit comments

Comments
 (0)