diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-03 15:36:09 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-03 20:11:20 -0800 |
| commit | 9db593c90af04dbf8f9bebb8a3650ff9609d10f2 (patch) | |
| tree | abd54c9f3907c4189f3b8a2fca708de20898c0e1 /src/liballoc | |
| parent | 74f7e0693909a45f9159c6d2ef72b42fcb4f1bac (diff) | |
| parent | d30f225b492163b14005d5069b7924f3fecf868c (diff) | |
| download | rust-9db593c90af04dbf8f9bebb8a3650ff9609d10f2.tar.gz rust-9db593c90af04dbf8f9bebb8a3650ff9609d10f2.zip | |
rollup merge of #21907: alexcrichton/iter-by-ref
This removes the `ByRef` iterator adaptor to stay in line with the changes to `std::io`. The `by_ref` method instead just returns `&mut Self`. This also removes the implementation of `Iterator for &mut Iterator` and instead generalizes it to `Iterator for &mut I` where `I: Iterator + ?Sized`. The `Box<I>` implementations were also updated.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 504b58d8ad1..340a8d59612 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -45,22 +45,18 @@ #![stable(feature = "rust1", since = "1.0.0")] +use core::prelude::*; + use core::any::Any; -use core::clone::Clone; -use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; +use core::cmp::Ordering; use core::default::Default; use core::error::{Error, FromError}; use core::fmt; use core::hash::{self, Hash}; -use core::iter::Iterator; -use core::marker::Sized; use core::mem; use core::ops::{Deref, DerefMut}; -use core::option::Option; use core::ptr::Unique; use core::raw::TraitObject; -use core::result::Result::{Ok, Err}; -use core::result::Result; /// A value that represents the heap. This is the default place that the `box` keyword allocates /// into when no place is supplied. @@ -296,18 +292,20 @@ impl<T: ?Sized> DerefMut for Box<T> { fn deref_mut(&mut self) -> &mut T { &mut **self } } -impl<'a, T> Iterator for Box<Iterator<Item=T> + 'a> { - type Item = T; - - fn next(&mut self) -> Option<T> { - (**self).next() - } - - fn size_hint(&self) -> (usize, Option<usize>) { - (**self).size_hint() - } +#[stable(feature = "rust1", since = "1.0.0")] +impl<I: Iterator + ?Sized> Iterator for Box<I> { + type Item = I::Item; + fn next(&mut self) -> Option<I::Item> { (**self).next() } + fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() } +} +#[stable(feature = "rust1", since = "1.0.0")] +impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> { + fn next_back(&mut self) -> Option<I::Item> { (**self).next_back() } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {} +#[stable(feature = "rust1", since = "1.0.0")] impl<'a, E: Error + 'a> FromError<E> for Box<Error + 'a> { fn from_error(err: E) -> Box<Error + 'a> { Box::new(err) |
