diff options
| author | Florian Wilkens <floya@live.de> | 2014-12-19 21:52:10 +0100 |
|---|---|---|
| committer | Florian Wilkens <floya@live.de> | 2014-12-22 12:58:55 +0100 |
| commit | f8cfd2480b69a1cc266fc91d0b60c825a9dc18a7 (patch) | |
| tree | 6d0eff18d899f6a660797fa3fa4265fd59ad4ed7 /src/libcollections | |
| parent | 34d680009205de2302b902d8f9f5f7ae7a042f1a (diff) | |
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].
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/binary_heap.rs | 29 | ||||
| -rw-r--r-- | src/libcollections/bit.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/btree/node.rs | 12 | ||||
| -rw-r--r-- | src/libcollections/btree/set.rs | 40 | ||||
| -rw-r--r-- | src/libcollections/dlist.rs | 46 | ||||
| -rw-r--r-- | src/libcollections/enum_set.rs | 14 | ||||
| -rw-r--r-- | src/libcollections/ring_buf.rs | 40 | ||||
| -rw-r--r-- | src/libcollections/slice.rs | 12 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 18 | ||||
| -rw-r--r-- | src/libcollections/vec_map.rs | 16 |
10 files changed, 114 insertions, 115 deletions
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 0840e8ec881..c9d1d9d13fb 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -239,9 +239,8 @@ impl<T: Ord> BinaryHeap<T> { /// } /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter(&self) -> Items<T> { - Items { iter: self.data.iter() } - } + pub fn iter(&self) -> Iter<T> { + Iter { iter: self.data.iter() } } /// Creates a consuming iterator, that is, one that moves each value out of /// the binary heap in arbitrary order. The binary heap cannot be used @@ -260,8 +259,8 @@ impl<T: Ord> BinaryHeap<T> { /// } /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(self) -> MoveItems<T> { - MoveItems { iter: self.data.into_iter() } + pub fn into_iter(self) -> IntoIter<T> { + IntoIter { iter: self.data.into_iter() } } /// Returns the greatest item in a queue, or `None` if it is empty. @@ -571,11 +570,11 @@ impl<T: Ord> BinaryHeap<T> { } /// `BinaryHeap` iterator. -pub struct Items<'a, T: 'a> { - iter: slice::Items<'a, T>, +pub struct Iter <'a, T: 'a> { + iter: slice::Iter<'a, T>, } -impl<'a, T> Iterator<&'a T> for Items<'a, T> { +impl<'a, T> Iterator<&'a T> for Iter<'a, T> { #[inline] fn next(&mut self) -> Option<&'a T> { self.iter.next() } @@ -583,19 +582,19 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> { fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } -impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> { +impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> { #[inline] fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() } } -impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {} /// An iterator that moves out of a `BinaryHeap`. -pub struct MoveItems<T> { - iter: vec::MoveItems<T>, +pub struct IntoIter<T> { + iter: vec::IntoIter<T>, } -impl<T> Iterator<T> for MoveItems<T> { +impl<T> Iterator<T> for IntoIter<T> { #[inline] fn next(&mut self) -> Option<T> { self.iter.next() } @@ -603,12 +602,12 @@ impl<T> Iterator<T> for MoveItems<T> { fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } -impl<T> DoubleEndedIterator<T> for MoveItems<T> { +impl<T> DoubleEndedIterator<T> for IntoIter<T> { #[inline] fn next_back(&mut self) -> Option<T> { self.iter.next_back() } } -impl<T> ExactSizeIterator<T> for MoveItems<T> {} +impl<T> ExactSizeIterator<T> for IntoIter<T> {} /// An iterator that drains a `BinaryHeap`. pub struct Drain<'a, T: 'a> { diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 17dbf8a2cae..8ceeb99d585 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -145,7 +145,7 @@ impl Index<uint,bool> for Bitv { } struct MaskWords<'a> { - iter: slice::Items<'a, u32>, + iter: slice::Iter<'a, u32>, next_word: Option<&'a u32>, last_word_mask: u32, offset: uint diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index 86c7def49b1..2c3c546fdb7 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -1382,14 +1382,14 @@ pub enum TraversalItem<K, V, E> { } /// A traversal over a node's entries and edges -pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>, - slice::Items<'a, V>>, - slice::Items<'a, Node<K, V>>>>; +pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>, + slice::Iter<'a, V>>, + slice::Iter<'a, Node<K, V>>>>; /// A mutable traversal over a node's entries and edges -pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>, - slice::MutItems<'a, V>>, - slice::MutItems<'a, Node<K, V>>>>; +pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>, + slice::IterMut<'a, V>>, + slice::IterMut<'a, Node<K, V>>>>; /// An owning traversal over a node's entries and edges pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>; diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index e4328a3cb20..26e82994f56 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -33,37 +33,37 @@ pub struct BTreeSet<T>{ } /// An iterator over a BTreeSet's items. -pub struct Items<'a, T: 'a> { +pub struct Iter<'a, T: 'a> { iter: Keys<'a, T, ()> } /// An owning iterator over a BTreeSet's items. -pub struct MoveItems<T> { +pub struct IntoIter<T> { iter: Map<(T, ()), T, MoveEntries<T, ()>, fn((T, ())) -> T> } /// A lazy iterator producing elements in the set difference (in-order). pub struct DifferenceItems<'a, T:'a> { - a: Peekable<&'a T, Items<'a, T>>, - b: Peekable<&'a T, Items<'a, T>>, + a: Peekable<&'a T, Iter<'a, T>>, + b: Peekable<&'a T, Iter<'a, T>>, } /// A lazy iterator producing elements in the set symmetric difference (in-order). pub struct SymDifferenceItems<'a, T:'a> { - a: Peekable<&'a T, Items<'a, T>>, - b: Peekable<&'a T, Items<'a, T>>, + a: Peekable<&'a T, Iter<'a, T>>, + b: Peekable<&'a T, Iter<'a, T>>, } /// A lazy iterator producing elements in the set intersection (in-order). pub struct IntersectionItems<'a, T:'a> { - a: Peekable<&'a T, Items<'a, T>>, - b: Peekable<&'a T, Items<'a, T>>, + a: Peekable<&'a T, Iter<'a, T>>, + b: Peekable<&'a T, Iter<'a, T>>, } /// A lazy iterator producing elements in the set union (in-order). pub struct UnionItems<'a, T:'a> { - a: Peekable<&'a T, Items<'a, T>>, - b: Peekable<&'a T, Items<'a, T>>, + a: Peekable<&'a T, Iter<'a, T>>, + b: Peekable<&'a T, Iter<'a, T>>, } impl<T: Ord> BTreeSet<T> { @@ -107,8 +107,8 @@ impl<T> BTreeSet<T> { /// assert_eq!(v, vec![1u,2,3,4]); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter<'a>(&'a self) -> Items<'a, T> { - Items { iter: self.map.keys() } + pub fn iter<'a>(&'a self) -> Iter<'a, T> { + Iter { iter: self.map.keys() } } /// Gets an iterator for moving out the BtreeSet's contents. @@ -124,10 +124,10 @@ impl<T> BTreeSet<T> { /// assert_eq!(v, vec![1u,2,3,4]); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(self) -> MoveItems<T> { + pub fn into_iter(self) -> IntoIter<T> { fn first<A, B>((a, _): (A, B)) -> A { a } - MoveItems { iter: self.map.into_iter().map(first) } + IntoIter { iter: self.map.into_iter().map(first) } } } @@ -544,24 +544,24 @@ impl<T: Show> Show for BTreeSet<T> { } } -impl<'a, T> Iterator<&'a T> for Items<'a, T> { +impl<'a, T> Iterator<&'a T> for Iter<'a, T> { fn next(&mut self) -> Option<&'a T> { self.iter.next() } fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } -impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> { +impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> { fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() } } -impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {} -impl<T> Iterator<T> for MoveItems<T> { +impl<T> Iterator<T> for IntoIter<T> { fn next(&mut self) -> Option<T> { self.iter.next() } fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } -impl<T> DoubleEndedIterator<T> for MoveItems<T> { +impl<T> DoubleEndedIterator<T> for IntoIter<T> { fn next_back(&mut self) -> Option<T> { self.iter.next_back() } } -impl<T> ExactSizeIterator<T> for MoveItems<T> {} +impl<T> ExactSizeIterator<T> for IntoIter<T> {} /// Compare `x` and `y`, but return `short` if x is None and `long` if y is None fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>, diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index d3c1a0f81a3..eb057b48853 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -51,21 +51,21 @@ struct Node<T> { } /// An iterator over references to the items of a `DList`. -pub struct Items<'a, T:'a> { +pub struct Iter<'a, T:'a> { head: &'a Link<T>, tail: Rawlink<Node<T>>, nelem: uint, } // FIXME #11820: the &'a Option<> of the Link stops clone working. -impl<'a, T> Clone for Items<'a, T> { - fn clone(&self) -> Items<'a, T> { *self } +impl<'a, T> Clone for Iter<'a, T> { + fn clone(&self) -> Iter<'a, T> { *self } } -impl<'a,T> Copy for Items<'a,T> {} +impl<'a,T> Copy for Iter<'a,T> {} /// An iterator over mutable references to the items of a `DList`. -pub struct MutItems<'a, T:'a> { +pub struct IterMut<'a, T:'a> { list: &'a mut DList<T>, head: Rawlink<Node<T>>, tail: Rawlink<Node<T>>, @@ -74,7 +74,7 @@ pub struct MutItems<'a, T:'a> { /// An iterator over mutable references to the items of a `DList`. #[deriving(Clone)] -pub struct MoveItems<T> { +pub struct IntoIter<T> { list: DList<T> } @@ -394,19 +394,19 @@ impl<T> DList<T> { /// Provides a forward iterator. #[inline] #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter<'a>(&'a self) -> Items<'a, T> { - Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail} + pub fn iter<'a>(&'a self) -> Iter<'a, T> { + Iter{nelem: self.len(), head: &self.list_head, tail: self.list_tail} } /// Provides a forward iterator with mutable references. #[inline] #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { + pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { let head_raw = match self.list_head { Some(ref mut h) => Rawlink::some(&mut **h), None => Rawlink::none(), }; - MutItems{ + IterMut{ nelem: self.len(), head: head_raw, tail: self.list_tail, @@ -417,8 +417,8 @@ impl<T> DList<T> { /// Consumes the list into an iterator yielding elements by value. #[inline] #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(self) -> MoveItems<T> { - MoveItems{list: self} + pub fn into_iter(self) -> IntoIter<T> { + IntoIter{list: self} } /// Returns `true` if the `DList` is empty. @@ -579,7 +579,7 @@ impl<T> Drop for DList<T> { } -impl<'a, A> Iterator<&'a A> for Items<'a, A> { +impl<'a, A> Iterator<&'a A> for Iter<'a, A> { #[inline] fn next(&mut self) -> Option<&'a A> { if self.nelem == 0 { @@ -598,7 +598,7 @@ impl<'a, A> Iterator<&'a A> for Items<'a, A> { } } -impl<'a, A> DoubleEndedIterator<&'a A> for Items<'a, A> { +impl<'a, A> DoubleEndedIterator<&'a A> for Iter<'a, A> { #[inline] fn next_back(&mut self) -> Option<&'a A> { if self.nelem == 0 { @@ -612,9 +612,9 @@ impl<'a, A> DoubleEndedIterator<&'a A> for Items<'a, A> { } } -impl<'a, A> ExactSizeIterator<&'a A> for Items<'a, A> {} +impl<'a, A> ExactSizeIterator<&'a A> for Iter<'a, A> {} -impl<'a, A> Iterator<&'a mut A> for MutItems<'a, A> { +impl<'a, A> Iterator<&'a mut A> for IterMut<'a, A> { #[inline] fn next(&mut self) -> Option<&'a mut A> { if self.nelem == 0 { @@ -636,7 +636,7 @@ impl<'a, A> Iterator<&'a mut A> for MutItems<'a, A> { } } -impl<'a, A> DoubleEndedIterator<&'a mut A> for MutItems<'a, A> { +impl<'a, A> DoubleEndedIterator<&'a mut A> for IterMut<'a, A> { #[inline] fn next_back(&mut self) -> Option<&'a mut A> { if self.nelem == 0 { @@ -650,7 +650,7 @@ impl<'a, A> DoubleEndedIterator<&'a mut A> for MutItems<'a, A> { } } -impl<'a, A> ExactSizeIterator<&'a mut A> for MutItems<'a, A> {} +impl<'a, A> ExactSizeIterator<&'a mut A> for IterMut<'a, A> {} /// Allows mutating a `DList` while iterating. pub trait ListInsertion<A> { @@ -664,8 +664,8 @@ pub trait ListInsertion<A> { fn peek_next<'a>(&'a mut self) -> Option<&'a mut A>; } -// private methods for MutItems -impl<'a, A> MutItems<'a, A> { +// private methods for IterMut +impl<'a, A> IterMut<'a, A> { fn insert_next_node(&mut self, mut ins_node: Box<Node<A>>) { // Insert before `self.head` so that it is between the // previously yielded element and self.head. @@ -687,7 +687,7 @@ impl<'a, A> MutItems<'a, A> { } } -impl<'a, A> ListInsertion<A> for MutItems<'a, A> { +impl<'a, A> ListInsertion<A> for IterMut<'a, A> { #[inline] fn insert_next(&mut self, elt: A) { self.insert_next_node(box Node::new(elt)) @@ -702,7 +702,7 @@ impl<'a, A> ListInsertion<A> for MutItems<'a, A> { } } -impl<A> Iterator<A> for MoveItems<A> { +impl<A> Iterator<A> for IntoIter<A> { #[inline] fn next(&mut self) -> Option<A> { self.list.pop_front() } @@ -712,7 +712,7 @@ impl<A> Iterator<A> for MoveItems<A> { } } -impl<A> DoubleEndedIterator<A> for MoveItems<A> { +impl<A> DoubleEndedIterator<A> for IntoIter<A> { #[inline] fn next_back(&mut self) -> Option<A> { self.list.pop_back() } } diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index bb762f4fb4e..fd04ce94247 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -178,8 +178,8 @@ impl<E:CLike> EnumSet<E> { /// Returns an iterator over an `EnumSet`. #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter(&self) -> Items<E> { - Items::new(self.bits) + pub fn iter(&self) -> Iter<E> { + Iter::new(self.bits) } } @@ -208,18 +208,18 @@ impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> { } /// An iterator over an EnumSet -pub struct Items<E> { +pub struct Iter<E> { index: uint, bits: uint, } -impl<E:CLike> Items<E> { - fn new(bits: uint) -> Items<E> { - Items { index: 0, bits: bits } +impl<E:CLike> Iter<E> { + fn new(bits: uint) -> Iter<E> { + Iter { index: 0, bits: bits } } } -impl<E:CLike> Iterator<E> for Items<E> { +impl<E:CLike> Iterator<E> for Iter<E> { fn next(&mut self) -> Option<E> { if self.bits == 0 { return None; diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index aa0e33248fc..37c088f7453 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -376,8 +376,8 @@ impl<T> RingBuf<T> { /// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter(&self) -> Items<T> { - Items { + pub fn iter(&self) -> Iter<T> { + Iter { tail: self.tail, head: self.head, ring: unsafe { self.buffer_as_slice() } @@ -402,8 +402,8 @@ impl<T> RingBuf<T> { /// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { - MutItems { + pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { + IterMut { tail: self.tail, head: self.head, cap: self.cap, @@ -414,8 +414,8 @@ impl<T> RingBuf<T> { /// Consumes the list into an iterator yielding elements by value. #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(self) -> MoveItems<T> { - MoveItems { + pub fn into_iter(self) -> IntoIter<T> { + IntoIter { inner: self, } } @@ -1122,13 +1122,13 @@ fn count(tail: uint, head: uint, size: uint) -> uint { } /// `RingBuf` iterator. -pub struct Items<'a, T:'a> { +pub struct Iter<'a, T:'a> { ring: &'a [T], tail: uint, head: uint } -impl<'a, T> Iterator<&'a T> for Items<'a, T> { +impl<'a, T> Iterator<&'a T> for Iter<'a, T> { #[inline] fn next(&mut self) -> Option<&'a T> { if self.tail == self.head { @@ -1146,7 +1146,7 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> { } } -impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> { +impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> { #[inline] fn next_back(&mut self) -> Option<&'a T> { if self.tail == self.head { @@ -1157,9 +1157,9 @@ impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> { } } -impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {} -impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { +impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> { #[inline] fn indexable(&self) -> uint { let (len, _) = self.size_hint(); @@ -1177,11 +1177,11 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { } } -// FIXME This was implemented differently from Items because of a problem +// FIXME This was implemented differently from Iter because of a problem // with returning the mutable reference. I couldn't find a way to // make the lifetime checker happy so, but there should be a way. /// `RingBuf` mutable iterator. -pub struct MutItems<'a, T:'a> { +pub struct IterMut<'a, T:'a> { ptr: *mut T, tail: uint, head: uint, @@ -1189,7 +1189,7 @@ pub struct MutItems<'a, T:'a> { marker: marker::ContravariantLifetime<'a>, } -impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> { +impl<'a, T> Iterator<&'a mut T> for IterMut<'a, T> { #[inline] fn next(&mut self) -> Option<&'a mut T> { if self.tail == self.head { @@ -1210,7 +1210,7 @@ impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> { } } -impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> { +impl<'a, T> DoubleEndedIterator<&'a mut T> for IterMut<'a, T> { #[inline] fn next_back(&mut self) -> Option<&'a mut T> { if self.tail == self.head { @@ -1224,14 +1224,14 @@ impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> { } } -impl<'a, T> ExactSizeIterator<&'a mut T> for MutItems<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a mut T> for IterMut<'a, T> {} // A by-value RingBuf iterator -pub struct MoveItems<T> { +pub struct IntoIter<T> { inner: RingBuf<T>, } -impl<T> Iterator<T> for MoveItems<T> { +impl<T> Iterator<T> for IntoIter<T> { #[inline] fn next(&mut self) -> Option<T> { self.inner.pop_front() @@ -1244,14 +1244,14 @@ impl<T> Iterator<T> for MoveItems<T> { } } -impl<T> DoubleEndedIterator<T> for MoveItems<T> { +impl<T> DoubleEndedIterator<T> for IntoIter<T> { #[inline] fn next_back(&mut self) -> Option<T> { self.inner.pop_back() } } -impl<T> ExactSizeIterator<T> for MoveItems<T> {} +impl<T> ExactSizeIterator<T> for IntoIter<T> {} /// A draining RingBuf iterator pub struct Drain<'a, T: 'a> { diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 16adf6fa224..d6d94f57acf 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -37,7 +37,7 @@ //! //! ## Structs //! -//! There are several structs that are useful for slices, such as `Items`, which +//! There are several structs that are useful for slices, such as `Iter`, which //! represents iteration over a slice. //! //! ## Traits @@ -104,7 +104,7 @@ use self::Direction::*; use vec::Vec; pub use core::slice::{Chunks, AsSlice, SplitsN, Windows}; -pub use core::slice::{Items, MutItems, PartialEqSliceExt}; +pub use core::slice::{Iter, IterMut, PartialEqSliceExt}; pub use core::slice::{ImmutableIntSlice, MutableIntSlice}; pub use core::slice::{MutSplits, MutChunks, Splits}; pub use core::slice::{bytes, mut_ref_slice, ref_slice}; @@ -771,7 +771,7 @@ pub trait SliceExt<T> for Sized? { /// Returns an iterator over the slice #[unstable = "iterator type may change"] - fn iter(&self) -> Items<T>; + fn iter(&self) -> Iter<T>; /// Returns an iterator over subslices separated by elements that match /// `pred`. The matched element is not contained in the subslices. @@ -970,7 +970,7 @@ pub trait SliceExt<T> for Sized? { /// Returns an iterator that allows modifying each value #[unstable = "waiting on iterator type name conventions"] - fn iter_mut(&mut self) -> MutItems<T>; + fn iter_mut(&mut self) -> IterMut<T>; /// Returns a mutable pointer to the first element of a slice, or `None` if it is empty #[unstable = "name may change"] @@ -1137,7 +1137,7 @@ impl<T> SliceExt<T> for [T] { } #[inline] - fn iter<'a>(&'a self) -> Items<'a, T> { + fn iter<'a>(&'a self) -> Iter<'a, T> { core_slice::SliceExt::iter(self) } @@ -1246,7 +1246,7 @@ impl<T> SliceExt<T> for [T] { } #[inline] - fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { + fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { core_slice::SliceExt::iter_mut(self) } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index b82c7e4cba2..fa0e4a2340e 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -888,7 +888,7 @@ impl<T> Vec<T> { /// ``` #[inline] #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(self) -> MoveItems<T> { + pub fn into_iter(self) -> IntoIter<T> { unsafe { let ptr = self.ptr; let cap = self.cap; @@ -899,7 +899,7 @@ impl<T> Vec<T> { ptr.offset(self.len() as int) as *const T }; mem::forget(self); - MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end } + IntoIter { allocation: ptr, cap: cap, ptr: begin, end: end } } } @@ -1402,21 +1402,21 @@ impl<T:fmt::Show> fmt::Show for Vec<T> { } /// An iterator that moves out of a vector. -pub struct MoveItems<T> { +pub struct IntoIter<T> { allocation: *mut T, // the block of memory allocated for the vector cap: uint, // the capacity of the vector ptr: *const T, end: *const T } -impl<T> MoveItems<T> { +impl<T> IntoIter<T> { /// Drops all items that have not yet been moved and returns the empty vector. #[inline] #[unstable] pub fn into_inner(mut self) -> Vec<T> { unsafe { for _x in self { } - let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self; + let IntoIter { allocation, cap, ptr: _ptr, end: _end } = self; mem::forget(self); Vec { ptr: allocation, cap: cap, len: 0 } } @@ -1427,7 +1427,7 @@ impl<T> MoveItems<T> { pub fn unwrap(self) -> Vec<T> { self.into_inner() } } -impl<T> Iterator<T> for MoveItems<T> { +impl<T> Iterator<T> for IntoIter<T> { #[inline] fn next<'a>(&'a mut self) -> Option<T> { unsafe { @@ -1461,7 +1461,7 @@ impl<T> Iterator<T> for MoveItems<T> { } } -impl<T> DoubleEndedIterator<T> for MoveItems<T> { +impl<T> DoubleEndedIterator<T> for IntoIter<T> { #[inline] fn next_back<'a>(&'a mut self) -> Option<T> { unsafe { @@ -1484,10 +1484,10 @@ impl<T> DoubleEndedIterator<T> for MoveItems<T> { } } -impl<T> ExactSizeIterator<T> for MoveItems<T> {} +impl<T> ExactSizeIterator<T> for IntoIter<T> {} #[unsafe_destructor] -impl<T> Drop for MoveItems<T> { +impl<T> Drop for IntoIter<T> { fn drop(&mut self) { // destroy the remaining elements if self.cap != 0 { diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 1babde6066d..802be427189 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -235,13 +235,13 @@ impl<V> VecMap<V> { /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] - pub fn into_iter(&mut self) -> MoveItems<V> { + pub fn into_iter(&mut self) -> IntoIter<V> { fn filter<A>((i, v): (uint, Option<A>)) -> Option<(uint, A)> { v.map(|v| (i, v)) } let values = replace(&mut self.v, vec!()); - MoveItems { iter: values.into_iter().enumerate().filter_map(filter) } + IntoIter { iter: values.into_iter().enumerate().filter_map(filter) } } /// Return the number of elements in the map. @@ -608,7 +608,7 @@ macro_rules! double_ended_iterator { pub struct Entries<'a, V:'a> { front: uint, back: uint, - iter: slice::Items<'a, Option<V>> + iter: slice::Iter<'a, Option<V>> } iterator! { impl Entries -> (uint, &'a V), as_ref } @@ -619,7 +619,7 @@ double_ended_iterator! { impl Entries -> (uint, &'a V), as_ref } pub struct MutEntries<'a, V:'a> { front: uint, back: uint, - iter: slice::MutItems<'a, Option<V>> + iter: slice::IterMut<'a, Option<V>> } iterator! { impl MutEntries -> (uint, &'a mut V), as_mut } @@ -636,11 +636,11 @@ pub struct Values<'a, V: 'a> { } /// A consuming iterator over the key-value pairs of a map. -pub struct MoveItems<V> { +pub struct IntoIter<V> { iter: FilterMap< (uint, Option<V>), (uint, V), - Enumerate<vec::MoveItems<Option<V>>>, + Enumerate<vec::IntoIter<Option<V>>>, fn((uint, Option<V>)) -> Option<(uint, V)>> } @@ -662,11 +662,11 @@ impl<'a, V> DoubleEndedIterator<&'a V> for Values<'a, V> { } -impl<V> Iterator<(uint, V)> for MoveItems<V> { +impl<V> Iterator<(uint, V)> for IntoIter<V> { fn next(&mut self) -> Option<(uint, V)> { self.iter.next() } fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } -impl<V> DoubleEndedIterator<(uint, V)> for MoveItems<V> { +impl<V> DoubleEndedIterator<(uint, V)> for IntoIter<V> { fn next_back(&mut self) -> Option<(uint, V)> { self.iter.next_back() } } |
