diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 06c29b47bf92..443b1567e1b4 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -694,6 +694,18 @@ impl Iterator for StepBy where I: Iterator { (f(inner_hint.0), inner_hint.1.map(f)) } } + + #[inline] + fn nth(&mut self, mut n: usize) -> Option { + if self.first_take { + if n == 0 { + self.first_take = false; + return self.iter.next() + } + n -= 1; + } + self.iter.nth(n * self.step) + } } // StepBy can only make the iterator shorter, so the len will still fit.