about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-03 12:32:56 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-03 12:41:23 -0800
commitd30f225b492163b14005d5069b7924f3fecf868c (patch)
tree11df52d8844878ce9db2f62238582a0dac2c2993 /src/liballoc
parent3b2ed14906fd9f9daa27cc7d1dad263d2f5ff450 (diff)
downloadrust-d30f225b492163b14005d5069b7924f3fecf868c.tar.gz
rust-d30f225b492163b14005d5069b7924f3fecf868c.zip
std: Remove `iter::ByRef` and generalize impls
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.

This is a breaking change due to the removal of the `std::iter::ByRef` type. All
mentions of `ByRef<'a, T>` should be replaced with `&mut T` to migrate forward.

[breaking-change]
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs32
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)