Skip to content

Commit 3b10858

Browse files
committed
Change Iterator::nth to use self.next() in a while loop.
Currently it uses `for x in self`, which seems dubious within an iterator method. Furthermore, `self.next()` is used in all the other iterator methods.
1 parent 5a0ac05 commit 3b10858

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/iter/traits/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub trait Iterator {
333333
#[inline]
334334
#[stable(feature = "rust1", since = "1.0.0")]
335335
fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
336-
for x in self {
336+
while let Some(x) = self.next() {
337337
if n == 0 {
338338
return Some(x);
339339
}

0 commit comments

Comments
 (0)