Skip to content

Commit e727378

Browse files
author
Jorge Aparicio
committed
add an associated Item type to IntoIterator
1 parent cf636c2 commit e727378

File tree

15 files changed

+441
-0
lines changed

15 files changed

+441
-0
lines changed

src/libcollections/binary_heap.rs

+24
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
655655
}
656656
}
657657

658+
// NOTE(stage0): remove impl after a snapshot
659+
#[cfg(stage0)]
658660
impl<T: Ord> IntoIterator for BinaryHeap<T> {
659661
type IntoIter = IntoIter<T>;
660662

@@ -663,6 +665,18 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
663665
}
664666
}
665667

668+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
669+
impl<T: Ord> IntoIterator for BinaryHeap<T> {
670+
type Item = T;
671+
type IntoIter = IntoIter<T>;
672+
673+
fn into_iter(self) -> IntoIter<T> {
674+
self.into_iter()
675+
}
676+
}
677+
678+
// NOTE(stage0): remove impl after a snapshot
679+
#[cfg(stage0)]
666680
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
667681
type IntoIter = Iter<'a, T>;
668682

@@ -671,6 +685,16 @@ impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
671685
}
672686
}
673687

688+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
689+
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
690+
type Item = &'a T;
691+
type IntoIter = Iter<'a, T>;
692+
693+
fn into_iter(self) -> Iter<'a, T> {
694+
self.iter()
695+
}
696+
}
697+
674698
#[stable(feature = "rust1", since = "1.0.0")]
675699
impl<T: Ord> Extend<T> for BinaryHeap<T> {
676700
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {

src/libcollections/bit.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,8 @@ impl<'a> RandomAccessIterator for Iter<'a> {
10701070
}
10711071
}
10721072

1073+
// NOTE(stage0): remove impl after a snapshot
1074+
#[cfg(stage0)]
10731075
impl<'a> IntoIterator for &'a Bitv {
10741076
type IntoIter = Iter<'a>;
10751077

@@ -1078,6 +1080,16 @@ impl<'a> IntoIterator for &'a Bitv {
10781080
}
10791081
}
10801082

1083+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1084+
impl<'a> IntoIterator for &'a Bitv {
1085+
type Item = bool;
1086+
type IntoIter = Iter<'a>;
1087+
1088+
fn into_iter(self) -> Iter<'a> {
1089+
self.iter()
1090+
}
1091+
}
1092+
10811093
/// An implementation of a set using a bit vector as an underlying
10821094
/// representation for holding unsigned numerical elements.
10831095
///
@@ -1882,6 +1894,8 @@ impl<'a> Iterator for SymmetricDifference<'a> {
18821894
#[inline] fn size_hint(&self) -> (usize, Option<usize>) { self.0.size_hint() }
18831895
}
18841896

1897+
// NOTE(stage0): remove impl after a snapshot
1898+
#[cfg(stage0)]
18851899
impl<'a> IntoIterator for &'a BitvSet {
18861900
type IntoIter = SetIter<'a>;
18871901

@@ -1890,6 +1904,16 @@ impl<'a> IntoIterator for &'a BitvSet {
18901904
}
18911905
}
18921906

1907+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1908+
impl<'a> IntoIterator for &'a BitvSet {
1909+
type Item = usize;
1910+
type IntoIter = SetIter<'a>;
1911+
1912+
fn into_iter(self) -> SetIter<'a> {
1913+
self.iter()
1914+
}
1915+
}
1916+
18931917
#[cfg(test)]
18941918
mod tests {
18951919
use prelude::*;

src/libcollections/btree/map.rs

+36
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
462462
}
463463
}
464464

465+
// NOTE(stage0): remove impl after a snapshot
466+
#[cfg(stage0)]
465467
impl<K, V> IntoIterator for BTreeMap<K, V> {
466468
type IntoIter = IntoIter<K, V>;
467469

@@ -470,6 +472,18 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
470472
}
471473
}
472474

475+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
476+
impl<K, V> IntoIterator for BTreeMap<K, V> {
477+
type Item = (K, V);
478+
type IntoIter = IntoIter<K, V>;
479+
480+
fn into_iter(self) -> IntoIter<K, V> {
481+
self.into_iter()
482+
}
483+
}
484+
485+
// NOTE(stage0): remove impl after a snapshot
486+
#[cfg(stage0)]
473487
impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
474488
type IntoIter = Iter<'a, K, V>;
475489

@@ -478,6 +492,18 @@ impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
478492
}
479493
}
480494

495+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
496+
impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
497+
type Item = (&'a K, &'a V);
498+
type IntoIter = Iter<'a, K, V>;
499+
500+
fn into_iter(self) -> Iter<'a, K, V> {
501+
self.iter()
502+
}
503+
}
504+
505+
// NOTE(stage0): remove impl after a snapshot
506+
#[cfg(stage0)]
481507
impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
482508
type IntoIter = IterMut<'a, K, V>;
483509

@@ -486,6 +512,16 @@ impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
486512
}
487513
}
488514

515+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
516+
impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
517+
type Item = (&'a K, &'a mut V);
518+
type IntoIter = IterMut<'a, K, V>;
519+
520+
fn into_iter(mut self) -> IterMut<'a, K, V> {
521+
self.iter_mut()
522+
}
523+
}
524+
489525
/// A helper enum useful for deciding whether to continue a loop since we can't
490526
/// return from a closure
491527
enum Continuation<A, B> {

src/libcollections/btree/set.rs

+24
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {
480480
}
481481
}
482482

483+
// NOTE(stage0): remove impl after a snapshot
484+
#[cfg(stage0)]
483485
impl<T> IntoIterator for BTreeSet<T> {
484486
type IntoIter = IntoIter<T>;
485487

@@ -488,6 +490,18 @@ impl<T> IntoIterator for BTreeSet<T> {
488490
}
489491
}
490492

493+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
494+
impl<T> IntoIterator for BTreeSet<T> {
495+
type Item = T;
496+
type IntoIter = IntoIter<T>;
497+
498+
fn into_iter(self) -> IntoIter<T> {
499+
self.into_iter()
500+
}
501+
}
502+
503+
// NOTE(stage0): remove impl after a snapshot
504+
#[cfg(stage0)]
491505
impl<'a, T> IntoIterator for &'a BTreeSet<T> {
492506
type IntoIter = Iter<'a, T>;
493507

@@ -496,6 +510,16 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
496510
}
497511
}
498512

513+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
514+
impl<'a, T> IntoIterator for &'a BTreeSet<T> {
515+
type Item = &'a T;
516+
type IntoIter = Iter<'a, T>;
517+
518+
fn into_iter(self) -> Iter<'a, T> {
519+
self.iter()
520+
}
521+
}
522+
499523
#[stable(feature = "rust1", since = "1.0.0")]
500524
impl<T: Ord> Extend<T> for BTreeSet<T> {
501525
#[inline]

src/libcollections/dlist.rs

+36
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ impl<A> FromIterator<A> for DList<A> {
830830
}
831831
}
832832

833+
// NOTE(stage0): remove impl after a snapshot
834+
#[cfg(stage0)]
833835
impl<T> IntoIterator for DList<T> {
834836
type IntoIter = IntoIter<T>;
835837

@@ -838,15 +840,49 @@ impl<T> IntoIterator for DList<T> {
838840
}
839841
}
840842

843+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
844+
impl<T> IntoIterator for DList<T> {
845+
type Item = T;
846+
type IntoIter = IntoIter<T>;
847+
848+
fn into_iter(self) -> IntoIter<T> {
849+
self.into_iter()
850+
}
851+
}
852+
853+
// NOTE(stage0): remove impl after a snapshot
854+
#[cfg(stage0)]
855+
impl<'a, T> IntoIterator for &'a DList<T> {
856+
type IntoIter = Iter<'a, T>;
857+
858+
fn into_iter(self) -> Iter<'a, T> {
859+
self.iter()
860+
}
861+
}
862+
863+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
841864
impl<'a, T> IntoIterator for &'a DList<T> {
865+
type Item = &'a T;
842866
type IntoIter = Iter<'a, T>;
843867

844868
fn into_iter(self) -> Iter<'a, T> {
845869
self.iter()
846870
}
847871
}
848872

873+
// NOTE(stage0): remove impl after a snapshot
874+
#[cfg(stage0)]
875+
impl<'a, T> IntoIterator for &'a mut DList<T> {
876+
type IntoIter = IterMut<'a, T>;
877+
878+
fn into_iter(mut self) -> IterMut<'a, T> {
879+
self.iter_mut()
880+
}
881+
}
882+
883+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
849884
impl<'a, T> IntoIterator for &'a mut DList<T> {
885+
type Item = &'a mut T;
850886
type IntoIter = IterMut<'a, T>;
851887

852888
fn into_iter(mut self) -> IterMut<'a, T> {

src/libcollections/enum_set.rs

+12
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ impl<E:CLike> FromIterator<E> for EnumSet<E> {
257257
}
258258
}
259259

260+
// NOTE(stage0): remove impl after a snapshot
261+
#[cfg(stage0)]
260262
impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
261263
type IntoIter = Iter<E>;
262264

@@ -265,6 +267,16 @@ impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
265267
}
266268
}
267269

270+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
271+
impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
272+
type Item = E;
273+
type IntoIter = Iter<E>;
274+
275+
fn into_iter(self) -> Iter<E> {
276+
self.iter()
277+
}
278+
}
279+
268280
impl<E:CLike> Extend<E> for EnumSet<E> {
269281
fn extend<I: Iterator<Item=E>>(&mut self, iterator: I) {
270282
for element in iterator {

src/libcollections/ring_buf.rs

+36
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,8 @@ impl<A> FromIterator<A> for RingBuf<A> {
16071607
}
16081608
}
16091609

1610+
// NOTE(stage0): remove impl after a snapshot
1611+
#[cfg(stage0)]
16101612
impl<T> IntoIterator for RingBuf<T> {
16111613
type IntoIter = IntoIter<T>;
16121614

@@ -1615,6 +1617,18 @@ impl<T> IntoIterator for RingBuf<T> {
16151617
}
16161618
}
16171619

1620+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1621+
impl<T> IntoIterator for RingBuf<T> {
1622+
type Item = T;
1623+
type IntoIter = IntoIter<T>;
1624+
1625+
fn into_iter(self) -> IntoIter<T> {
1626+
self.into_iter()
1627+
}
1628+
}
1629+
1630+
// NOTE(stage0): remove impl after a snapshot
1631+
#[cfg(stage0)]
16181632
impl<'a, T> IntoIterator for &'a RingBuf<T> {
16191633
type IntoIter = Iter<'a, T>;
16201634

@@ -1623,6 +1637,18 @@ impl<'a, T> IntoIterator for &'a RingBuf<T> {
16231637
}
16241638
}
16251639

1640+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1641+
impl<'a, T> IntoIterator for &'a RingBuf<T> {
1642+
type Item = &'a T;
1643+
type IntoIter = Iter<'a, T>;
1644+
1645+
fn into_iter(self) -> Iter<'a, T> {
1646+
self.iter()
1647+
}
1648+
}
1649+
1650+
// NOTE(stage0): remove impl after a snapshot
1651+
#[cfg(stage0)]
16261652
impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
16271653
type IntoIter = IterMut<'a, T>;
16281654

@@ -1631,6 +1657,16 @@ impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
16311657
}
16321658
}
16331659

1660+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1661+
impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
1662+
type Item = &'a mut T;
1663+
type IntoIter = IterMut<'a, T>;
1664+
1665+
fn into_iter(mut self) -> IterMut<'a, T> {
1666+
self.iter_mut()
1667+
}
1668+
}
1669+
16341670
#[stable(feature = "rust1", since = "1.0.0")]
16351671
impl<A> Extend<A> for RingBuf<A> {
16361672
fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {

0 commit comments

Comments
 (0)