diff options
| author | Clar Fon <them@lightdark.xyz> | 2018-12-17 21:10:53 -0500 |
|---|---|---|
| committer | Clar Fon <them@lightdark.xyz> | 2019-01-22 17:45:11 -0500 |
| commit | 52b36e28d8e7dab1897c450f5c658885117d887d (patch) | |
| tree | a16bc24b085501f873be75ebe839b8c2f77c1526 | |
| parent | 53b400c30cfb73fc622186086e7315c751f5cb91 (diff) | |
| download | rust-52b36e28d8e7dab1897c450f5c658885117d887d.tar.gz rust-52b36e28d8e7dab1897c450f5c658885117d887d.zip | |
Move super_nth out of ZipImpl
| -rw-r--r-- | src/libcore/iter/adapters/zip.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libcore/iter/adapters/zip.rs b/src/libcore/iter/adapters/zip.rs index 6a0a7d8b12c..a27af53f39c 100644 --- a/src/libcore/iter/adapters/zip.rs +++ b/src/libcore/iter/adapters/zip.rs @@ -18,6 +18,15 @@ pub struct Zip<A, B> { index: usize, len: usize, } +impl<A: Iterator, B: Iterator> Zip<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 + } +} #[stable(feature = "rust1", since = "1.0.0")] 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> { fn next(&mut self) -> Option<Self::Item>; fn size_hint(&self) -> (usize, Option<usize>); fn nth(&mut self, n: usize) -> Option<Self::Item>; - fn super_nth(&mut self, mut n: usize) -> Option<Self::Item> { - while let Some(x) = self.next() { - if n == 0 { return Some(x) } - n -= 1; - } - None - } fn next_back(&mut self) -> Option<Self::Item> where A: DoubleEndedIterator + ExactSizeIterator, B: DoubleEndedIterator + ExactSizeIterator; |
