diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-04-18 23:44:02 +0200 | 
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-04-18 23:44:02 +0200 | 
| commit | 1cd8d1e2b95e95d4fb7e3340d174532d1aee9d7c (patch) | |
| tree | a587d44d9b343cdd2a722b88dbc080ab359b40bc /src | |
| parent | 085fddac50a808d2013a86b5ae11297cd31adcb3 (diff) | |
| download | rust-1cd8d1e2b95e95d4fb7e3340d174532d1aee9d7c.tar.gz rust-1cd8d1e2b95e95d4fb7e3340d174532d1aee9d7c.zip | |
core::iter: Move ExactSizeIterator impls to each struct definition
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/iter/mod.rs | 38 | 
1 files changed, 19 insertions, 19 deletions
| diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 8449ee78501..abc199cd182 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -333,25 +333,6 @@ mod range; mod sources; mod traits; -// All adaptors that preserve the size of the wrapped iterator are fine -// Adaptors that may overflow in `size_hint` are not, i.e. `Chain`. -#[stable(feature = "rust1", since = "1.0.0")] -impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {} -#[stable(feature = "rust1", since = "1.0.0")] -impl<I: ExactSizeIterator, F> ExactSizeIterator for Inspect<I, F> where - F: FnMut(&I::Item), -{} -#[stable(feature = "rust1", since = "1.0.0")] -impl<I> ExactSizeIterator for Rev<I> - where I: ExactSizeIterator + DoubleEndedIterator {} -#[stable(feature = "rust1", since = "1.0.0")] -impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F> where - F: FnMut(I::Item) -> B, -{} -#[stable(feature = "rust1", since = "1.0.0")] -impl<A, B> ExactSizeIterator for Zip<A, B> - where A: ExactSizeIterator, B: ExactSizeIterator {} - /// An double-ended iterator with the direction inverted. /// /// This `struct` is created by the [`rev()`] method on [`Iterator`]. See its @@ -382,6 +363,10 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator { fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<I> ExactSizeIterator for Rev<I> + where I: ExactSizeIterator + DoubleEndedIterator {} + /// An iterator that clones the elements of an underlying iterator. /// /// This `struct` is created by the [`cloned()`] method on [`Iterator`]. See its @@ -679,6 +664,10 @@ impl<A, B> DoubleEndedIterator for Zip<A, B> where } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<A, B> ExactSizeIterator for Zip<A, B> + where A: ExactSizeIterator, B: ExactSizeIterator {} + /// An iterator that maps the values of `iter` with `f`. /// /// This `struct` is created by the [`map()`] method on [`Iterator`]. See its @@ -771,6 +760,10 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F> + where F: FnMut(I::Item) -> B {} + /// An iterator that filters the elements of `iter` with `predicate`. /// /// This `struct` is created by the [`filter()`] method on [`Iterator`]. See its @@ -966,6 +959,9 @@ impl<I> DoubleEndedIterator for Enumerate<I> where } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {} + /// An iterator with a `peek()` that returns an optional reference to the next /// element. /// @@ -1655,3 +1651,7 @@ impl<I: DoubleEndedIterator, F> DoubleEndedIterator for Inspect<I, F> self.do_inspect(next) } } + +#[stable(feature = "rust1", since = "1.0.0")] +impl<I: ExactSizeIterator, F> ExactSizeIterator for Inspect<I, F> + where F: FnMut(&I::Item) {} | 
