diff --git a/src/libcollectionstest/vec_deque.rs b/src/libcollectionstest/vec_deque.rs index 38f358c1505..fe752d5a7e1 100644 --- a/src/libcollectionstest/vec_deque.rs +++ b/src/libcollectionstest/vec_deque.rs @@ -360,7 +360,7 @@ fn test_mut_rev_iter_wrap() { assert_eq!(d.pop_front(), Some(1)); d.push_back(4); - assert_eq!(d.iter_mut().rev().cloned().collect::>(), + assert_eq!(d.iter_mut().rev().map(|x| *x).collect::>(), vec![4, 3, 2]); } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 8ebedb66851..4f8b1c21ab2 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -65,7 +65,7 @@ use default::Default; use marker; use mem; use num::{ToPrimitive, Int}; -use ops::{Add, Deref, FnMut, RangeFrom}; +use ops::{Add, FnMut, RangeFrom}; use option::Option; use option::Option::{Some, None}; use marker::Sized; @@ -976,12 +976,11 @@ pub trait IteratorExt: Iterator + Sized { (ts, us) } - /// Creates an iterator that clones the elements it yields. Useful for converting an - /// Iterator<&T> to an Iterator. - #[unstable(feature = "core", reason = "recent addition")] - fn cloned(self) -> Cloned where - Self::Item: Deref, - ::Target: Clone, + /// Creates an iterator that clones the elements it yields. Useful for + /// converting an Iterator<&T> to an Iterator. + #[stable(feature = "rust1", since = "1.0.0")] + fn cloned<'a, T: 'a>(self) -> Cloned + where Self: Iterator, T: Clone { Cloned { it: self } } @@ -1279,14 +1278,12 @@ pub struct Cloned { } #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for Cloned where - I: Iterator, - I::Item: Deref, - ::Target: Clone +impl<'a, I, T: 'a> Iterator for Cloned + where I: Iterator, T: Clone { - type Item = ::Target; + type Item = T; - fn next(&mut self) -> Option<::Item> { + fn next(&mut self) -> Option { self.it.next().cloned() } @@ -1296,28 +1293,22 @@ impl Iterator for Cloned where } #[stable(feature = "rust1", since = "1.0.0")] -impl DoubleEndedIterator for Cloned where - I: DoubleEndedIterator, - I::Item: Deref, - ::Target: Clone +impl<'a, I, T: 'a> DoubleEndedIterator for Cloned + where I: DoubleEndedIterator, T: Clone { - fn next_back(&mut self) -> Option<::Item> { + fn next_back(&mut self) -> Option { self.it.next_back().cloned() } } #[stable(feature = "rust1", since = "1.0.0")] -impl ExactSizeIterator for Cloned where - I: ExactSizeIterator, - I::Item: Deref, - ::Target: Clone +impl<'a, I, T: 'a> ExactSizeIterator for Cloned + where I: ExactSizeIterator, T: Clone {} #[unstable(feature = "core", reason = "trait is experimental")] -impl RandomAccessIterator for Cloned where - I: RandomAccessIterator, - I::Item: Deref, - ::Target: Clone +impl<'a, I, T: 'a> RandomAccessIterator for Cloned + where I: RandomAccessIterator, T: Clone { #[inline] fn indexable(&self) -> usize { @@ -1325,7 +1316,7 @@ impl RandomAccessIterator for Cloned where } #[inline] - fn idx(&mut self, index: usize) -> Option<::Item> { + fn idx(&mut self, index: usize) -> Option { self.it.idx(index).cloned() } }