Skip to content

Commit f8cfd24

Browse files
committed
Renaming of the Iter types as in RFC #344
libcore: slice::Items -> slice::Iter, slice::MutItems -> slice::IterMut libcollections: *::Items -> *::Iter, *::MoveItems -> *::IntoIter, *::MutItems -> *::IterMut This is of course a [breaking-change].
1 parent 34d6800 commit f8cfd24

File tree

26 files changed

+173
-175
lines changed

26 files changed

+173
-175
lines changed

src/libcollections/binary_heap.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,8 @@ impl<T: Ord> BinaryHeap<T> {
239239
/// }
240240
/// ```
241241
#[unstable = "matches collection reform specification, waiting for dust to settle"]
242-
pub fn iter(&self) -> Items<T> {
243-
Items { iter: self.data.iter() }
244-
}
242+
pub fn iter(&self) -> Iter<T> {
243+
Iter { iter: self.data.iter() } }
245244

246245
/// Creates a consuming iterator, that is, one that moves each value out of
247246
/// the binary heap in arbitrary order. The binary heap cannot be used
@@ -260,8 +259,8 @@ impl<T: Ord> BinaryHeap<T> {
260259
/// }
261260
/// ```
262261
#[unstable = "matches collection reform specification, waiting for dust to settle"]
263-
pub fn into_iter(self) -> MoveItems<T> {
264-
MoveItems { iter: self.data.into_iter() }
262+
pub fn into_iter(self) -> IntoIter<T> {
263+
IntoIter { iter: self.data.into_iter() }
265264
}
266265

267266
/// Returns the greatest item in a queue, or `None` if it is empty.
@@ -571,44 +570,44 @@ impl<T: Ord> BinaryHeap<T> {
571570
}
572571

573572
/// `BinaryHeap` iterator.
574-
pub struct Items<'a, T: 'a> {
575-
iter: slice::Items<'a, T>,
573+
pub struct Iter <'a, T: 'a> {
574+
iter: slice::Iter<'a, T>,
576575
}
577576

578-
impl<'a, T> Iterator<&'a T> for Items<'a, T> {
577+
impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
579578
#[inline]
580579
fn next(&mut self) -> Option<&'a T> { self.iter.next() }
581580

582581
#[inline]
583582
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
584583
}
585584

586-
impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
585+
impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
587586
#[inline]
588587
fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
589588
}
590589

591-
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
590+
impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}
592591

593592
/// An iterator that moves out of a `BinaryHeap`.
594-
pub struct MoveItems<T> {
595-
iter: vec::MoveItems<T>,
593+
pub struct IntoIter<T> {
594+
iter: vec::IntoIter<T>,
596595
}
597596

598-
impl<T> Iterator<T> for MoveItems<T> {
597+
impl<T> Iterator<T> for IntoIter<T> {
599598
#[inline]
600599
fn next(&mut self) -> Option<T> { self.iter.next() }
601600

602601
#[inline]
603602
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
604603
}
605604

606-
impl<T> DoubleEndedIterator<T> for MoveItems<T> {
605+
impl<T> DoubleEndedIterator<T> for IntoIter<T> {
607606
#[inline]
608607
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
609608
}
610609

611-
impl<T> ExactSizeIterator<T> for MoveItems<T> {}
610+
impl<T> ExactSizeIterator<T> for IntoIter<T> {}
612611

613612
/// An iterator that drains a `BinaryHeap`.
614613
pub struct Drain<'a, T: 'a> {

src/libcollections/bit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Index<uint,bool> for Bitv {
145145
}
146146

147147
struct MaskWords<'a> {
148-
iter: slice::Items<'a, u32>,
148+
iter: slice::Iter<'a, u32>,
149149
next_word: Option<&'a u32>,
150150
last_word_mask: u32,
151151
offset: uint

src/libcollections/btree/node.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1382,14 +1382,14 @@ pub enum TraversalItem<K, V, E> {
13821382
}
13831383

13841384
/// A traversal over a node's entries and edges
1385-
pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>,
1386-
slice::Items<'a, V>>,
1387-
slice::Items<'a, Node<K, V>>>>;
1385+
pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
1386+
slice::Iter<'a, V>>,
1387+
slice::Iter<'a, Node<K, V>>>>;
13881388

13891389
/// A mutable traversal over a node's entries and edges
1390-
pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>,
1391-
slice::MutItems<'a, V>>,
1392-
slice::MutItems<'a, Node<K, V>>>>;
1390+
pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
1391+
slice::IterMut<'a, V>>,
1392+
slice::IterMut<'a, Node<K, V>>>>;
13931393

13941394
/// An owning traversal over a node's entries and edges
13951395
pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>;

src/libcollections/btree/set.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,37 @@ pub struct BTreeSet<T>{
3333
}
3434

3535
/// An iterator over a BTreeSet's items.
36-
pub struct Items<'a, T: 'a> {
36+
pub struct Iter<'a, T: 'a> {
3737
iter: Keys<'a, T, ()>
3838
}
3939

4040
/// An owning iterator over a BTreeSet's items.
41-
pub struct MoveItems<T> {
41+
pub struct IntoIter<T> {
4242
iter: Map<(T, ()), T, MoveEntries<T, ()>, fn((T, ())) -> T>
4343
}
4444

4545
/// A lazy iterator producing elements in the set difference (in-order).
4646
pub struct DifferenceItems<'a, T:'a> {
47-
a: Peekable<&'a T, Items<'a, T>>,
48-
b: Peekable<&'a T, Items<'a, T>>,
47+
a: Peekable<&'a T, Iter<'a, T>>,
48+
b: Peekable<&'a T, Iter<'a, T>>,
4949
}
5050

5151
/// A lazy iterator producing elements in the set symmetric difference (in-order).
5252
pub struct SymDifferenceItems<'a, T:'a> {
53-
a: Peekable<&'a T, Items<'a, T>>,
54-
b: Peekable<&'a T, Items<'a, T>>,
53+
a: Peekable<&'a T, Iter<'a, T>>,
54+
b: Peekable<&'a T, Iter<'a, T>>,
5555
}
5656

5757
/// A lazy iterator producing elements in the set intersection (in-order).
5858
pub struct IntersectionItems<'a, T:'a> {
59-
a: Peekable<&'a T, Items<'a, T>>,
60-
b: Peekable<&'a T, Items<'a, T>>,
59+
a: Peekable<&'a T, Iter<'a, T>>,
60+
b: Peekable<&'a T, Iter<'a, T>>,
6161
}
6262

6363
/// A lazy iterator producing elements in the set union (in-order).
6464
pub struct UnionItems<'a, T:'a> {
65-
a: Peekable<&'a T, Items<'a, T>>,
66-
b: Peekable<&'a T, Items<'a, T>>,
65+
a: Peekable<&'a T, Iter<'a, T>>,
66+
b: Peekable<&'a T, Iter<'a, T>>,
6767
}
6868

6969
impl<T: Ord> BTreeSet<T> {
@@ -107,8 +107,8 @@ impl<T> BTreeSet<T> {
107107
/// assert_eq!(v, vec![1u,2,3,4]);
108108
/// ```
109109
#[unstable = "matches collection reform specification, waiting for dust to settle"]
110-
pub fn iter<'a>(&'a self) -> Items<'a, T> {
111-
Items { iter: self.map.keys() }
110+
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
111+
Iter { iter: self.map.keys() }
112112
}
113113

114114
/// Gets an iterator for moving out the BtreeSet's contents.
@@ -124,10 +124,10 @@ impl<T> BTreeSet<T> {
124124
/// assert_eq!(v, vec![1u,2,3,4]);
125125
/// ```
126126
#[unstable = "matches collection reform specification, waiting for dust to settle"]
127-
pub fn into_iter(self) -> MoveItems<T> {
127+
pub fn into_iter(self) -> IntoIter<T> {
128128
fn first<A, B>((a, _): (A, B)) -> A { a }
129129

130-
MoveItems { iter: self.map.into_iter().map(first) }
130+
IntoIter { iter: self.map.into_iter().map(first) }
131131
}
132132
}
133133

@@ -544,24 +544,24 @@ impl<T: Show> Show for BTreeSet<T> {
544544
}
545545
}
546546

547-
impl<'a, T> Iterator<&'a T> for Items<'a, T> {
547+
impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
548548
fn next(&mut self) -> Option<&'a T> { self.iter.next() }
549549
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
550550
}
551-
impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
551+
impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
552552
fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
553553
}
554-
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
554+
impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}
555555

556556

557-
impl<T> Iterator<T> for MoveItems<T> {
557+
impl<T> Iterator<T> for IntoIter<T> {
558558
fn next(&mut self) -> Option<T> { self.iter.next() }
559559
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
560560
}
561-
impl<T> DoubleEndedIterator<T> for MoveItems<T> {
561+
impl<T> DoubleEndedIterator<T> for IntoIter<T> {
562562
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
563563
}
564-
impl<T> ExactSizeIterator<T> for MoveItems<T> {}
564+
impl<T> ExactSizeIterator<T> for IntoIter<T> {}
565565

566566
/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
567567
fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,

src/libcollections/dlist.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ struct Node<T> {
5151
}
5252

5353
/// An iterator over references to the items of a `DList`.
54-
pub struct Items<'a, T:'a> {
54+
pub struct Iter<'a, T:'a> {
5555
head: &'a Link<T>,
5656
tail: Rawlink<Node<T>>,
5757
nelem: uint,
5858
}
5959

6060
// FIXME #11820: the &'a Option<> of the Link stops clone working.
61-
impl<'a, T> Clone for Items<'a, T> {
62-
fn clone(&self) -> Items<'a, T> { *self }
61+
impl<'a, T> Clone for Iter<'a, T> {
62+
fn clone(&self) -> Iter<'a, T> { *self }
6363
}
6464

65-
impl<'a,T> Copy for Items<'a,T> {}
65+
impl<'a,T> Copy for Iter<'a,T> {}
6666

6767
/// An iterator over mutable references to the items of a `DList`.
68-
pub struct MutItems<'a, T:'a> {
68+
pub struct IterMut<'a, T:'a> {
6969
list: &'a mut DList<T>,
7070
head: Rawlink<Node<T>>,
7171
tail: Rawlink<Node<T>>,
@@ -74,7 +74,7 @@ pub struct MutItems<'a, T:'a> {
7474

7575
/// An iterator over mutable references to the items of a `DList`.
7676
#[deriving(Clone)]
77-
pub struct MoveItems<T> {
77+
pub struct IntoIter<T> {
7878
list: DList<T>
7979
}
8080

@@ -394,19 +394,19 @@ impl<T> DList<T> {
394394
/// Provides a forward iterator.
395395
#[inline]
396396
#[unstable = "matches collection reform specification, waiting for dust to settle"]
397-
pub fn iter<'a>(&'a self) -> Items<'a, T> {
398-
Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
397+
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
398+
Iter{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
399399
}
400400

401401
/// Provides a forward iterator with mutable references.
402402
#[inline]
403403
#[unstable = "matches collection reform specification, waiting for dust to settle"]
404-
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
404+
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
405405
let head_raw = match self.list_head {
406406
Some(ref mut h) => Rawlink::some(&mut **h),
407407
None => Rawlink::none(),
408408
};
409-
MutItems{
409+
IterMut{
410410
nelem: self.len(),
411411
head: head_raw,
412412
tail: self.list_tail,
@@ -417,8 +417,8 @@ impl<T> DList<T> {
417417
/// Consumes the list into an iterator yielding elements by value.
418418
#[inline]
419419
#[unstable = "matches collection reform specification, waiting for dust to settle"]
420-
pub fn into_iter(self) -> MoveItems<T> {
421-
MoveItems{list: self}
420+
pub fn into_iter(self) -> IntoIter<T> {
421+
IntoIter{list: self}
422422
}
423423

424424
/// Returns `true` if the `DList` is empty.
@@ -579,7 +579,7 @@ impl<T> Drop for DList<T> {
579579
}
580580

581581

582-
impl<'a, A> Iterator<&'a A> for Items<'a, A> {
582+
impl<'a, A> Iterator<&'a A> for Iter<'a, A> {
583583
#[inline]
584584
fn next(&mut self) -> Option<&'a A> {
585585
if self.nelem == 0 {
@@ -598,7 +598,7 @@ impl<'a, A> Iterator<&'a A> for Items<'a, A> {
598598
}
599599
}
600600

601-
impl<'a, A> DoubleEndedIterator<&'a A> for Items<'a, A> {
601+
impl<'a, A> DoubleEndedIterator<&'a A> for Iter<'a, A> {
602602
#[inline]
603603
fn next_back(&mut self) -> Option<&'a A> {
604604
if self.nelem == 0 {
@@ -612,9 +612,9 @@ impl<'a, A> DoubleEndedIterator<&'a A> for Items<'a, A> {
612612
}
613613
}
614614

615-
impl<'a, A> ExactSizeIterator<&'a A> for Items<'a, A> {}
615+
impl<'a, A> ExactSizeIterator<&'a A> for Iter<'a, A> {}
616616

617-
impl<'a, A> Iterator<&'a mut A> for MutItems<'a, A> {
617+
impl<'a, A> Iterator<&'a mut A> for IterMut<'a, A> {
618618
#[inline]
619619
fn next(&mut self) -> Option<&'a mut A> {
620620
if self.nelem == 0 {
@@ -636,7 +636,7 @@ impl<'a, A> Iterator<&'a mut A> for MutItems<'a, A> {
636636
}
637637
}
638638

639-
impl<'a, A> DoubleEndedIterator<&'a mut A> for MutItems<'a, A> {
639+
impl<'a, A> DoubleEndedIterator<&'a mut A> for IterMut<'a, A> {
640640
#[inline]
641641
fn next_back(&mut self) -> Option<&'a mut A> {
642642
if self.nelem == 0 {
@@ -650,7 +650,7 @@ impl<'a, A> DoubleEndedIterator<&'a mut A> for MutItems<'a, A> {
650650
}
651651
}
652652

653-
impl<'a, A> ExactSizeIterator<&'a mut A> for MutItems<'a, A> {}
653+
impl<'a, A> ExactSizeIterator<&'a mut A> for IterMut<'a, A> {}
654654

655655
/// Allows mutating a `DList` while iterating.
656656
pub trait ListInsertion<A> {
@@ -664,8 +664,8 @@ pub trait ListInsertion<A> {
664664
fn peek_next<'a>(&'a mut self) -> Option<&'a mut A>;
665665
}
666666

667-
// private methods for MutItems
668-
impl<'a, A> MutItems<'a, A> {
667+
// private methods for IterMut
668+
impl<'a, A> IterMut<'a, A> {
669669
fn insert_next_node(&mut self, mut ins_node: Box<Node<A>>) {
670670
// Insert before `self.head` so that it is between the
671671
// previously yielded element and self.head.
@@ -687,7 +687,7 @@ impl<'a, A> MutItems<'a, A> {
687687
}
688688
}
689689

690-
impl<'a, A> ListInsertion<A> for MutItems<'a, A> {
690+
impl<'a, A> ListInsertion<A> for IterMut<'a, A> {
691691
#[inline]
692692
fn insert_next(&mut self, elt: A) {
693693
self.insert_next_node(box Node::new(elt))
@@ -702,7 +702,7 @@ impl<'a, A> ListInsertion<A> for MutItems<'a, A> {
702702
}
703703
}
704704

705-
impl<A> Iterator<A> for MoveItems<A> {
705+
impl<A> Iterator<A> for IntoIter<A> {
706706
#[inline]
707707
fn next(&mut self) -> Option<A> { self.list.pop_front() }
708708

@@ -712,7 +712,7 @@ impl<A> Iterator<A> for MoveItems<A> {
712712
}
713713
}
714714

715-
impl<A> DoubleEndedIterator<A> for MoveItems<A> {
715+
impl<A> DoubleEndedIterator<A> for IntoIter<A> {
716716
#[inline]
717717
fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
718718
}

0 commit comments

Comments
 (0)