Rollup merge of #22313 - japaric:iter, r=aturon

`IntoIterator` now has an extra associated item:

``` rust
trait IntoIterator {
    type Item;
    type IntoIter: Iterator<Self=Self::Item>;
}
```

This lets you bind the iterator \"`Item`\" directly when writing generic functions:

``` rust
// hypothetical change, not included in this PR
impl Extend<T> for Vec<T> {
    // you can now write
    fn extend<I>(&mut self, it: I) where I: IntoIterator<Item=T> { .. }
    // instead of
    fn extend<I: IntoIterator>(&mut self, it: I) where I::IntoIter: Iterator<Item=T> { .. }
}
```

The downside is that now you have to write an extra associated type in your `IntoIterator` implementations:

``` diff
 impl<T> IntoIterator for Vec<T> {
+    type Item = T;
     type IntoIter = IntoIter<T>;

     fn into_iter(self) -> IntoIter<T> { .. }
 }
```

Because this breaks all downstream implementations of `IntoIterator`, this is a [breaking-change]

---

r? @aturon
This commit is contained in:
Manish Goregaokar 2015-02-16 11:30:21 +05:30
commit d264ef2b11
15 changed files with 441 additions and 0 deletions

View File

@ -655,6 +655,8 @@ impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T: Ord> IntoIterator for BinaryHeap<T> {
type IntoIter = IntoIter<T>;
@ -663,6 +665,18 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T: Ord> IntoIterator for BinaryHeap<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
type IntoIter = Iter<'a, T>;
@ -671,6 +685,16 @@ impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a BinaryHeap<T> 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<T: Ord> Extend<T> for BinaryHeap<T> {
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {

View File

@ -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<usize>) { 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::*;

View File

@ -462,6 +462,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<K, V> IntoIterator for BTreeMap<K, V> {
type IntoIter = IntoIter<K, V>;
@ -470,6 +472,18 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<K, V> IntoIterator for BTreeMap<K, V> {
type Item = (K, V);
type IntoIter = IntoIter<K, V>;
fn into_iter(self) -> IntoIter<K, V> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
type IntoIter = Iter<'a, K, V>;
@ -478,6 +492,18 @@ impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
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<K, V> {
type IntoIter = IterMut<'a, K, V>;
@ -486,6 +512,16 @@ impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
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<A, B> {

View File

@ -480,6 +480,8 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for BTreeSet<T> {
type IntoIter = IntoIter<T>;
@ -488,6 +490,18 @@ impl<T> IntoIterator for BTreeSet<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for BTreeSet<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a BTreeSet<T> {
type IntoIter = Iter<'a, T>;
@ -496,6 +510,16 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a BTreeSet<T> {
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<T: Ord> Extend<T> for BTreeSet<T> {
#[inline]

View File

@ -837,6 +837,8 @@ impl<A> FromIterator<A> for DList<A> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for DList<T> {
type IntoIter = IntoIter<T>;
@ -845,6 +847,18 @@ impl<T> IntoIterator for DList<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for DList<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a DList<T> {
type IntoIter = Iter<'a, T>;
@ -853,6 +867,18 @@ impl<'a, T> IntoIterator for &'a DList<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a DList<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 DList<T> {
type IntoIter = IterMut<'a, T>;
@ -861,6 +887,16 @@ impl<'a, T> IntoIterator for &'a mut DList<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a mut DList<T> {
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<A> Extend<A> for DList<A> {
fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {

View File

@ -257,6 +257,8 @@ impl<E:CLike> FromIterator<E> for EnumSet<E> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
type IntoIter = Iter<E>;
@ -265,6 +267,16 @@ impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
type Item = E;
type IntoIter = Iter<E>;
fn into_iter(self) -> Iter<E> {
self.iter()
}
}
impl<E:CLike> Extend<E> for EnumSet<E> {
fn extend<I: Iterator<Item=E>>(&mut self, iterator: I) {
for element in iterator {

View File

@ -1699,6 +1699,8 @@ impl<A> FromIterator<A> for RingBuf<A> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for RingBuf<T> {
type IntoIter = IntoIter<T>;
@ -1707,6 +1709,18 @@ impl<T> IntoIterator for RingBuf<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for RingBuf<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a RingBuf<T> {
type IntoIter = Iter<'a, T>;
@ -1715,6 +1729,18 @@ impl<'a, T> IntoIterator for &'a RingBuf<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a RingBuf<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 RingBuf<T> {
type IntoIter = IterMut<'a, T>;
@ -1723,6 +1749,16 @@ impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
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<A> Extend<A> for RingBuf<A> {
fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {

View File

@ -1403,6 +1403,8 @@ impl<T> FromIterator<T> for Vec<T> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for Vec<T> {
type IntoIter = IntoIter<T>;
@ -1411,6 +1413,18 @@ impl<T> IntoIterator for Vec<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for Vec<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a Vec<T> {
type IntoIter = slice::Iter<'a, T>;
@ -1419,6 +1433,18 @@ impl<'a, T> IntoIterator for &'a Vec<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a Vec<T> {
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<T> {
type IntoIter = slice::IterMut<'a, T>;
@ -1427,6 +1453,16 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a mut Vec<T> {
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<T> Extend<T> for Vec<T> {
#[inline]

View File

@ -668,6 +668,8 @@ impl<V> FromIterator<(usize, V)> for VecMap<V> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for VecMap<T> {
type IntoIter = IntoIter<T>;
@ -676,6 +678,18 @@ impl<T> IntoIterator for VecMap<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for VecMap<T> {
type Item = (usize, T);
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> IntoIterator for &'a VecMap<T> {
type IntoIter = Iter<'a, T>;
@ -684,6 +698,18 @@ impl<'a, T> IntoIterator for &'a VecMap<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a VecMap<T> {
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<T> {
type IntoIter = IterMut<'a, T>;
@ -692,6 +718,16 @@ impl<'a, T> IntoIterator for &'a mut VecMap<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> IntoIterator for &'a mut VecMap<T> {
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<V> Extend<(usize, V)> for VecMap<V> {
fn extend<Iter: Iterator<Item=(usize, V)>>(&mut self, iter: Iter) {

View File

@ -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<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
#[inline]

View File

@ -118,6 +118,8 @@ pub trait FromIterator<A> {
fn from_iter<T: Iterator<Item=A>>(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<Item=Self::Item>;
/// 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<I> IntoIterator for I where I: Iterator {
type IntoIter = I;
@ -135,6 +150,16 @@ impl<I> IntoIterator for I where I: Iterator {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<I: Iterator> 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<A> {

View File

@ -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) => {

View File

@ -530,6 +530,8 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> {
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> IntoIterator for VecPerParamSpace<T> {
type IntoIter = IntoIter<T>;
@ -538,6 +540,18 @@ impl<T> IntoIterator for VecPerParamSpace<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> IntoIterator for VecPerParamSpace<T> {
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_vec().into_iter()
}
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
type IntoIter = Iter<'a, T>;
@ -546,6 +560,16 @@ impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
type Item = &'a T;
type IntoIter = Iter<'a, T>;
fn into_iter(self) -> Iter<'a, T> {
self.as_slice().into_iter()
}
}
///////////////////////////////////////////////////////////////////////////
// Public trait `Subst`

View File

@ -1372,6 +1372,8 @@ enum VacantEntryState<K, V, M> {
NoElem(EmptyBucket<K, V, M>),
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
@ -1384,6 +1386,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
H: hash::Hasher<Output=u64>
{
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<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
@ -1396,6 +1414,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap<K, V, S>
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
H: hash::Hasher<Output=u64>
{
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<K, V, S, H> IntoIterator for HashMap<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
@ -1408,6 +1442,20 @@ impl<K, V, S, H> IntoIterator for HashMap<K, V, S>
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<K, V, S, H> IntoIterator for HashMap<K, V, S>
where K: Eq + Hash<H>,
S: HashState<Hasher=H>,
H: hash::Hasher<Output=u64>
{
type Item = (K, V);
type IntoIter = IntoIter<K, V>;
fn into_iter(self) -> IntoIter<K, V> {
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);

View File

@ -835,6 +835,8 @@ pub struct Union<'a, T: 'a, S: 'a> {
iter: Chain<Iter<'a, T>, Difference<'a, T, S>>
}
// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
where T: Eq + Hash<H>,
S: HashState<Hasher=H>,
@ -847,6 +849,22 @@ impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
where T: Eq + Hash<H>,
S: HashState<Hasher=H>,
H: hash::Hasher<Output=u64>
{
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<T, S, H> IntoIterator for HashSet<T, S>
where T: Eq + Hash<H>,
S: HashState<Hasher=H>,
@ -859,6 +877,20 @@ impl<T, S, H> IntoIterator for HashSet<T, S>
}
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T, S, H> IntoIterator for HashSet<T, S>
where T: Eq + Hash<H>,
S: HashState<Hasher=H>,
H: hash::Hasher<Output=u64>
{
type Item = T;
type IntoIter = IntoIter<T>;
fn into_iter(self) -> IntoIter<T> {
self.into_iter()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K> Iterator for Iter<'a, K> {
type Item = &'a K;