Skip to content

Commit 52b36e2

Browse files
author
Clar Fon
committed
Move super_nth out of ZipImpl
1 parent 53b400c commit 52b36e2

File tree

1 file changed

+9
-7
lines changed
  • src/libcore/iter/adapters

1 file changed

+9
-7
lines changed

src/libcore/iter/adapters/zip.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ pub struct Zip<A, B> {
1818
index: usize,
1919
len: usize,
2020
}
21+
impl<A: Iterator, B: Iterator> Zip<A, B> {
22+
fn super_nth(&mut self, mut n: usize) -> Option<(A::Item, B::Item)> {
23+
while let Some(x) = Iterator::next(self) {
24+
if n == 0 { return Some(x) }
25+
n -= 1;
26+
}
27+
None
28+
}
29+
}
2130

2231
#[stable(feature = "rust1", since = "1.0.0")]
2332
impl<A, B> Iterator for Zip<A, B> where A: Iterator, B: Iterator
@@ -59,13 +68,6 @@ pub(in super::super) trait ZipImpl<A, B> {
5968
fn next(&mut self) -> Option<Self::Item>;
6069
fn size_hint(&self) -> (usize, Option<usize>);
6170
fn nth(&mut self, n: usize) -> Option<Self::Item>;
62-
fn super_nth(&mut self, mut n: usize) -> Option<Self::Item> {
63-
while let Some(x) = self.next() {
64-
if n == 0 { return Some(x) }
65-
n -= 1;
66-
}
67-
None
68-
}
6971
fn next_back(&mut self) -> Option<Self::Item>
7072
where A: DoubleEndedIterator + ExactSizeIterator,
7173
B: DoubleEndedIterator + ExactSizeIterator;

0 commit comments

Comments
 (0)