Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use advance_by instead of nth in Skip::next
Combined with the `iter::Cloned::advance_by` implementation this leads to fewer clone operations
  • Loading branch information
the8472 committed Jan 6, 2022
commit fe6ff67df19fbcf57fbc8e0ec00b2d96abd69b80
2 changes: 1 addition & 1 deletion library/core/src/iter/adapters/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
#[inline]
fn next(&mut self) -> Option<I::Item> {
if unlikely(self.n > 0) {
self.iter.nth(crate::mem::take(&mut self.n) - 1);
let _ = self.iter.advance_by(crate::mem::take(&mut self.n));
}
self.iter.next()
}
Expand Down