diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 66374b639c1..1d994839d99 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -655,6 +655,8 @@ impl FromIterator for BinaryHeap { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for BinaryHeap { type IntoIter = IntoIter; @@ -663,6 +665,18 @@ impl IntoIterator for BinaryHeap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for BinaryHeap { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a BinaryHeap where T: Ord { type IntoIter = Iter<'a, T>; @@ -671,6 +685,16 @@ impl<'a, T> IntoIterator for &'a BinaryHeap where T: Ord { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a BinaryHeap where T: Ord { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Extend for BinaryHeap { fn extend>(&mut self, iter: Iter) { diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 6d15a264172..ca598a8d4d2 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -1070,6 +1070,8 @@ impl<'a> RandomAccessIterator for Iter<'a> { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a> IntoIterator for &'a Bitv { type IntoIter = Iter<'a>; @@ -1078,6 +1080,16 @@ impl<'a> IntoIterator for &'a Bitv { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a> IntoIterator for &'a Bitv { + type Item = bool; + type IntoIter = Iter<'a>; + + fn into_iter(self) -> Iter<'a> { + self.iter() + } +} + /// An implementation of a set using a bit vector as an underlying /// representation for holding unsigned numerical elements. /// @@ -1882,6 +1894,8 @@ impl<'a> Iterator for SymmetricDifference<'a> { #[inline] fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a> IntoIterator for &'a BitvSet { type IntoIter = SetIter<'a>; @@ -1890,6 +1904,16 @@ impl<'a> IntoIterator for &'a BitvSet { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a> IntoIterator for &'a BitvSet { + type Item = usize; + type IntoIter = SetIter<'a>; + + fn into_iter(self) -> SetIter<'a> { + self.iter() + } +} + #[cfg(test)] mod tests { use prelude::*; diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 895fa076ab6..84f9825e989 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -462,6 +462,8 @@ impl BTreeMap { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for BTreeMap { type IntoIter = IntoIter; @@ -470,6 +472,18 @@ impl IntoIterator for BTreeMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for BTreeMap { + type Item = (K, V); + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, K, V> IntoIterator for &'a BTreeMap { type IntoIter = Iter<'a, K, V>; @@ -478,6 +492,18 @@ impl<'a, K, V> IntoIterator for &'a BTreeMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, K, V> IntoIterator for &'a BTreeMap { + type Item = (&'a K, &'a V); + type IntoIter = Iter<'a, K, V>; + + fn into_iter(self) -> Iter<'a, K, V> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, K, V> IntoIterator for &'a mut BTreeMap { type IntoIter = IterMut<'a, K, V>; @@ -486,6 +512,16 @@ impl<'a, K, V> IntoIterator for &'a mut BTreeMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, K, V> IntoIterator for &'a mut BTreeMap { + type Item = (&'a K, &'a mut V); + type IntoIter = IterMut<'a, K, V>; + + fn into_iter(mut self) -> IterMut<'a, K, V> { + self.iter_mut() + } +} + /// A helper enum useful for deciding whether to continue a loop since we can't /// return from a closure enum Continuation { diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 8628879295b..aecf5940311 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -480,6 +480,8 @@ impl FromIterator for BTreeSet { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for BTreeSet { type IntoIter = IntoIter; @@ -488,6 +490,18 @@ impl IntoIterator for BTreeSet { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for BTreeSet { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a BTreeSet { type IntoIter = Iter<'a, T>; @@ -496,6 +510,16 @@ impl<'a, T> IntoIterator for &'a BTreeSet { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a BTreeSet { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Extend for BTreeSet { #[inline] diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 423646e5acd..27b282ee9a9 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -837,6 +837,8 @@ impl FromIterator for DList { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for DList { type IntoIter = IntoIter; @@ -845,6 +847,18 @@ impl IntoIterator for DList { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for DList { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a DList { type IntoIter = Iter<'a, T>; @@ -853,6 +867,18 @@ impl<'a, T> IntoIterator for &'a DList { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a DList { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut DList { type IntoIter = IterMut<'a, T>; @@ -861,6 +887,16 @@ impl<'a, T> IntoIterator for &'a mut DList { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a mut DList { + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(mut self) -> IterMut<'a, T> { + self.iter_mut() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Extend for DList { fn extend>(&mut self, iterator: T) { diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index da533d34703..5c37be188fe 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -257,6 +257,8 @@ impl FromIterator for EnumSet { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, E> IntoIterator for &'a EnumSet where E: CLike { type IntoIter = Iter; @@ -265,6 +267,16 @@ impl<'a, E> IntoIterator for &'a EnumSet where E: CLike { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, E> IntoIterator for &'a EnumSet where E: CLike { + type Item = E; + type IntoIter = Iter; + + fn into_iter(self) -> Iter { + self.iter() + } +} + impl Extend for EnumSet { fn extend>(&mut self, iterator: I) { for element in iterator { diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index ec1e648939a..0a4ccde9236 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -1699,6 +1699,8 @@ impl FromIterator for RingBuf { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for RingBuf { type IntoIter = IntoIter; @@ -1707,6 +1709,18 @@ impl IntoIterator for RingBuf { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for RingBuf { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a RingBuf { type IntoIter = Iter<'a, T>; @@ -1715,6 +1729,18 @@ impl<'a, T> IntoIterator for &'a RingBuf { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a RingBuf { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut RingBuf { type IntoIter = IterMut<'a, T>; @@ -1723,6 +1749,16 @@ impl<'a, T> IntoIterator for &'a mut RingBuf { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a mut RingBuf { + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(mut self) -> IterMut<'a, T> { + self.iter_mut() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Extend for RingBuf { fn extend>(&mut self, iterator: T) { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 4fb8f52a57b..6653b960d8d 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1403,6 +1403,8 @@ impl FromIterator for Vec { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for Vec { type IntoIter = IntoIter; @@ -1411,6 +1413,18 @@ impl IntoIterator for Vec { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for Vec { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a Vec { type IntoIter = slice::Iter<'a, T>; @@ -1419,6 +1433,18 @@ impl<'a, T> IntoIterator for &'a Vec { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a Vec { + type Item = &'a T; + type IntoIter = slice::Iter<'a, T>; + + fn into_iter(self) -> slice::Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut Vec { type IntoIter = slice::IterMut<'a, T>; @@ -1427,6 +1453,16 @@ impl<'a, T> IntoIterator for &'a mut Vec { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a mut Vec { + type Item = &'a mut T; + type IntoIter = slice::IterMut<'a, T>; + + fn into_iter(mut self) -> slice::IterMut<'a, T> { + self.iter_mut() + } +} + #[unstable(feature = "collections", reason = "waiting on Extend stability")] impl Extend for Vec { #[inline] diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index ba358ada0ad..7f9484c58a1 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -668,6 +668,8 @@ impl FromIterator<(usize, V)> for VecMap { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for VecMap { type IntoIter = IntoIter; @@ -676,6 +678,18 @@ impl IntoIterator for VecMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for VecMap { + type Item = (usize, T); + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a VecMap { type IntoIter = Iter<'a, T>; @@ -684,6 +698,18 @@ impl<'a, T> IntoIterator for &'a VecMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a VecMap { + type Item = (usize, &'a T); + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut VecMap { type IntoIter = IterMut<'a, T>; @@ -692,6 +718,16 @@ impl<'a, T> IntoIterator for &'a mut VecMap { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a mut VecMap { + type Item = (usize, &'a mut T); + type IntoIter = IterMut<'a, T>; + + fn into_iter(mut self) -> IterMut<'a, T> { + self.iter_mut() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Extend<(usize, V)> for VecMap { fn extend>(&mut self, iter: Iter) { diff --git a/src/libcore/array.rs b/src/libcore/array.rs index a596fe4a588..abaa7594d04 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -48,6 +48,8 @@ macro_rules! array_impls { } } + // NOTE(stage0): remove impl after a snapshot + #[cfg(stage0)] impl<'a, T> IntoIterator for &'a [T; $N] { type IntoIter = Iter<'a, T>; @@ -56,6 +58,18 @@ macro_rules! array_impls { } } + #[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot + impl<'a, T> IntoIterator for &'a [T; $N] { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } + } + + // NOTE(stage0): remove impl after a snapshot + #[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut [T; $N] { type IntoIter = IterMut<'a, T>; @@ -64,6 +78,16 @@ macro_rules! array_impls { } } + #[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot + impl<'a, T> IntoIterator for &'a mut [T; $N] { + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } + } + #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq<[B; $N]> for [A; $N] where A: PartialEq { #[inline] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f4d560cb4c9..03c473ed967 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -118,6 +118,8 @@ pub trait FromIterator { fn from_iter>(iterator: T) -> Self; } +// NOTE(stage0): remove trait after a snapshot +#[cfg(stage0)] /// Conversion into an `Iterator` pub trait IntoIterator { type IntoIter: Iterator; @@ -127,6 +129,19 @@ pub trait IntoIterator { fn into_iter(self) -> Self::IntoIter; } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +/// Conversion into an `Iterator` +pub trait IntoIterator { + type Item; + type IntoIter: Iterator; + + /// Consumes `Self` and returns an iterator over it + #[stable(feature = "rust1", since = "1.0.0")] + fn into_iter(self) -> Self::IntoIter; +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for I where I: Iterator { type IntoIter = I; @@ -135,6 +150,16 @@ impl IntoIterator for I where I: Iterator { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for I { + type Item = I::Item; + type IntoIter = I; + + fn into_iter(self) -> I { + self + } +} + /// A type growable from an `Iterator` implementation #[stable(feature = "rust1", since = "1.0.0")] pub trait Extend { diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 097633b7063..cd91843f359 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -626,6 +626,8 @@ impl<'a, T> Default for &'a [T] { // Iterators // +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a [T] { type IntoIter = Iter<'a, T>; @@ -634,6 +636,18 @@ impl<'a, T> IntoIterator for &'a [T] { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a [T] { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T> IntoIterator for &'a mut [T] { type IntoIter = IterMut<'a, T>; @@ -642,6 +656,16 @@ impl<'a, T> IntoIterator for &'a mut [T] { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T> IntoIterator for &'a mut [T] { + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } +} + // The shared definition of the `Iter` and `IterMut` iterators macro_rules! iterator { (struct $name:ident -> $ptr:ty, $elem:ty) => { diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index e20968a9ac9..e27e7a80246 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -530,6 +530,8 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for VecPerParamSpace { type IntoIter = IntoIter; @@ -538,6 +540,18 @@ impl IntoIterator for VecPerParamSpace { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for VecPerParamSpace { + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_vec().into_iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a,T> IntoIterator for &'a VecPerParamSpace { type IntoIter = Iter<'a, T>; @@ -546,6 +560,16 @@ impl<'a,T> IntoIterator for &'a VecPerParamSpace { } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a,T> IntoIterator for &'a VecPerParamSpace { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.as_slice().into_iter() + } +} + /////////////////////////////////////////////////////////////////////////// // Public trait `Subst` diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 18dd122891d..241e409910f 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1372,6 +1372,8 @@ enum VacantEntryState { NoElem(EmptyBucket), } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, K, V, S, H> IntoIterator for &'a HashMap where K: Eq + Hash, S: HashState, @@ -1384,6 +1386,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a HashMap } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, K, V, S, H> IntoIterator for &'a HashMap + where K: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Item = (&'a K, &'a V); + type IntoIter = Iter<'a, K, V>; + + fn into_iter(self) -> Iter<'a, K, V> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap where K: Eq + Hash, S: HashState, @@ -1396,6 +1414,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap + where K: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Item = (&'a K, &'a mut V); + type IntoIter = IterMut<'a, K, V>; + + fn into_iter(mut self) -> IterMut<'a, K, V> { + self.iter_mut() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for HashMap where K: Eq + Hash, S: HashState, @@ -1408,6 +1442,20 @@ impl IntoIterator for HashMap } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for HashMap + where K: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Item = (K, V); + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Iterator for Iter<'a, K, V> { type Item = (&'a K, &'a V); diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 96af556dbcc..300e2089317 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -835,6 +835,8 @@ pub struct Union<'a, T: 'a, S: 'a> { iter: Chain, Difference<'a, T, S>> } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<'a, T, S, H> IntoIterator for &'a HashSet where T: Eq + Hash, S: HashState, @@ -847,6 +849,22 @@ impl<'a, T, S, H> IntoIterator for &'a HashSet } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<'a, T, S, H> IntoIterator for &'a HashSet + where T: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl IntoIterator for HashSet where T: Eq + Hash, S: HashState, @@ -859,6 +877,20 @@ impl IntoIterator for HashSet } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl IntoIterator for HashSet + where T: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K> Iterator for Iter<'a, K> { type Item = &'a K;