Skip to content

Commit

Permalink
refactor: updated zip nth() to iterator nth()
Browse files Browse the repository at this point in the history
When the iterator nth() method was updated it was not in zip.
Zip needs to implement nth() for the trusted length specialised implementation.
  • Loading branch information
DeveloperC286 committed Jan 26, 2021
1 parent 0597339 commit f2bb202
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions library/core/src/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ where
ZipNew::new(a, b)
}

fn super_nth(&mut self, mut n: usize) -> Option<(A::Item, B::Item)> {
while let Some(x) = Iterator::next(self) {
if n == 0 {
return Some(x);
}
n -= 1;
}
None
fn super_nth(&mut self, n: usize) -> Option<(A::Item, B::Item)> {
self.advance_by(n).ok()?;
self.next()
}
}

Expand Down

0 comments on commit f2bb202

Please sign in to comment.