rollup merge of #20056: MrFloya/iter_rename

Conflicts:
	src/libcollections/bit.rs
	src/libcore/str.rs
This commit is contained in:
Alex Crichton 2014-12-22 12:49:57 -08:00
commit 459f3b2cfa
30 changed files with 248 additions and 250 deletions

View File

@ -239,8 +239,8 @@ impl<T: Ord> BinaryHeap<T> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter(&self) -> Items<T> { pub fn iter(&self) -> Iter<T> {
Items { iter: self.data.iter() } Iter { iter: self.data.iter() }
} }
/// Creates a consuming iterator, that is, one that moves each value out of /// Creates a consuming iterator, that is, one that moves each value out of
@ -260,8 +260,8 @@ impl<T: Ord> BinaryHeap<T> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveItems<T> { pub fn into_iter(self) -> IntoIter<T> {
MoveItems { iter: self.data.into_iter() } IntoIter { iter: self.data.into_iter() }
} }
/// Returns the greatest item in a queue, or `None` if it is empty. /// Returns the greatest item in a queue, or `None` if it is empty.
@ -572,11 +572,11 @@ impl<T: Ord> BinaryHeap<T> {
} }
/// `BinaryHeap` iterator. /// `BinaryHeap` iterator.
pub struct Items<'a, T: 'a> { pub struct Iter <'a, T: 'a> {
iter: slice::Items<'a, T>, 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] #[inline]
fn next(&mut self) -> Option<&'a T> { self.iter.next() } fn next(&mut self) -> Option<&'a T> { self.iter.next() }
@ -584,19 +584,19 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } 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] #[inline]
fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() } 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`. /// An iterator that moves out of a `BinaryHeap`.
pub struct MoveItems<T> { pub struct IntoIter<T> {
iter: vec::MoveItems<T>, iter: vec::IntoIter<T>,
} }
impl<T> Iterator<T> for MoveItems<T> { impl<T> Iterator<T> for IntoIter<T> {
#[inline] #[inline]
fn next(&mut self) -> Option<T> { self.iter.next() } fn next(&mut self) -> Option<T> { self.iter.next() }
@ -604,12 +604,12 @@ impl<T> Iterator<T> for MoveItems<T> {
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } 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] #[inline]
fn next_back(&mut self) -> Option<T> { self.iter.next_back() } 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`. /// An iterator that drains a `BinaryHeap`.
pub struct Drain<'a, T: 'a> { pub struct Drain<'a, T: 'a> {

View File

@ -186,7 +186,6 @@ fn blocks_for_bits(bits: uint) -> uint {
} else { } else {
bits / u32::BITS + 1 bits / u32::BITS + 1
} }
} }
/// Computes the bitmask for the final word of the vector /// Computes the bitmask for the final word of the vector

View File

@ -88,7 +88,7 @@ pub struct BTreeMap<K, V> {
} }
/// An abstract base over-which all other BTree iterators are built. /// An abstract base over-which all other BTree iterators are built.
struct AbsEntries<T> { struct AbsIter<T> {
lca: T, lca: T,
left: RingBuf<T>, left: RingBuf<T>,
right: RingBuf<T>, right: RingBuf<T>,
@ -96,28 +96,28 @@ struct AbsEntries<T> {
} }
/// An iterator over a BTreeMap's entries. /// An iterator over a BTreeMap's entries.
pub struct Entries<'a, K: 'a, V: 'a> { pub struct Iter<'a, K: 'a, V: 'a> {
inner: AbsEntries<Traversal<'a, K, V>> inner: AbsIter<Traversal<'a, K, V>>
} }
/// A mutable iterator over a BTreeMap's entries. /// A mutable iterator over a BTreeMap's entries.
pub struct MutEntries<'a, K: 'a, V: 'a> { pub struct IterMut<'a, K: 'a, V: 'a> {
inner: AbsEntries<MutTraversal<'a, K, V>> inner: AbsIter<MutTraversal<'a, K, V>>
} }
/// An owning iterator over a BTreeMap's entries. /// An owning iterator over a BTreeMap's entries.
pub struct MoveEntries<K, V> { pub struct IntoIter<K, V> {
inner: AbsEntries<MoveTraversal<K, V>> inner: AbsIter<MoveTraversal<K, V>>
} }
/// An iterator over a BTreeMap's keys. /// An iterator over a BTreeMap's keys.
pub struct Keys<'a, K: 'a, V: 'a> { pub struct Keys<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K> inner: Map<(&'a K, &'a V), &'a K, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
} }
/// An iterator over a BTreeMap's values. /// An iterator over a BTreeMap's values.
pub struct Values<'a, K: 'a, V: 'a> { pub struct Values<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V> inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
} }
/// A view into a single entry in a map, which may either be vacant or occupied. /// A view into a single entry in a map, which may either be vacant or occupied.
@ -929,7 +929,7 @@ enum StackOp<T> {
} }
impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>> impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
Iterator<(K, V)> for AbsEntries<T> { Iterator<(K, V)> for AbsIter<T> {
// This function is pretty long, but only because there's a lot of cases to consider. // This function is pretty long, but only because there's a lot of cases to consider.
// Our iterator represents two search paths, left and right, to the smallest and largest // Our iterator represents two search paths, left and right, to the smallest and largest
// elements we have yet to yield. lca represents the least common ancestor of these two paths, // elements we have yet to yield. lca represents the least common ancestor of these two paths,
@ -995,7 +995,7 @@ impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
} }
impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>> impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
DoubleEndedIterator<(K, V)> for AbsEntries<T> { DoubleEndedIterator<(K, V)> for AbsIter<T> {
// next_back is totally symmetric to next // next_back is totally symmetric to next
fn next_back(&mut self) -> Option<(K, V)> { fn next_back(&mut self) -> Option<(K, V)> {
loop { loop {
@ -1032,34 +1032,34 @@ impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
} }
} }
impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> { impl<'a, K, V> Iterator<(&'a K, &'a V)> for Iter<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next() } fn next(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Entries<'a, K, V> { impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Iter<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() } fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() }
} }
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Entries<'a, K, V> {} impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Iter<'a, K, V> {}
impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> { impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() } fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> { impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() } fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
} }
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {} impl<'a, K, V> ExactSizeIterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {}
impl<K, V> Iterator<(K, V)> for MoveEntries<K, V> { impl<K, V> Iterator<(K, V)> for IntoIter<K, V> {
fn next(&mut self) -> Option<(K, V)> { self.inner.next() } fn next(&mut self) -> Option<(K, V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }
impl<K, V> DoubleEndedIterator<(K, V)> for MoveEntries<K, V> { impl<K, V> DoubleEndedIterator<(K, V)> for IntoIter<K, V> {
fn next_back(&mut self) -> Option<(K, V)> { self.inner.next_back() } fn next_back(&mut self) -> Option<(K, V)> { self.inner.next_back() }
} }
impl<K, V> ExactSizeIterator<(K, V)> for MoveEntries<K, V> {} impl<K, V> ExactSizeIterator<(K, V)> for IntoIter<K, V> {}
impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> { impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
@ -1140,10 +1140,10 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!((*first_key, *first_value), (1u, "a")); /// assert_eq!((*first_key, *first_value), (1u, "a"));
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter<'a>(&'a self) -> Entries<'a, K, V> { pub fn iter<'a>(&'a self) -> Iter<'a, K, V> {
let len = self.len(); let len = self.len();
Entries { Iter {
inner: AbsEntries { inner: AbsIter {
lca: Traverse::traverse(&self.root), lca: Traverse::traverse(&self.root),
left: RingBuf::new(), left: RingBuf::new(),
right: RingBuf::new(), right: RingBuf::new(),
@ -1172,10 +1172,10 @@ impl<K, V> BTreeMap<K, V> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter_mut<'a>(&'a mut self) -> MutEntries<'a, K, V> { pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, K, V> {
let len = self.len(); let len = self.len();
MutEntries { IterMut {
inner: AbsEntries { inner: AbsIter {
lca: Traverse::traverse(&mut self.root), lca: Traverse::traverse(&mut self.root),
left: RingBuf::new(), left: RingBuf::new(),
right: RingBuf::new(), right: RingBuf::new(),
@ -1201,10 +1201,10 @@ impl<K, V> BTreeMap<K, V> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveEntries<K, V> { pub fn into_iter(self) -> IntoIter<K, V> {
let len = self.len(); let len = self.len();
MoveEntries { IntoIter {
inner: AbsEntries { inner: AbsIter {
lca: Traverse::traverse(self.root), lca: Traverse::traverse(self.root),
left: RingBuf::new(), left: RingBuf::new(),
right: RingBuf::new(), right: RingBuf::new(),

View File

@ -1382,14 +1382,14 @@ pub enum TraversalItem<K, V, E> {
} }
/// A traversal over a node's entries and edges /// A traversal over a node's entries and edges
pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>, pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
slice::Items<'a, V>>, slice::Iter<'a, V>>,
slice::Items<'a, Node<K, V>>>>; slice::Iter<'a, Node<K, V>>>>;
/// A mutable traversal over a node's entries and edges /// A mutable traversal over a node's entries and edges
pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>, pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
slice::MutItems<'a, V>>, slice::IterMut<'a, V>>,
slice::MutItems<'a, Node<K, V>>>>; slice::IterMut<'a, Node<K, V>>>>;
/// An owning traversal over a node's entries and edges /// An owning traversal over a node's entries and edges
pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>; pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>;

View File

@ -13,7 +13,7 @@
use core::prelude::*; use core::prelude::*;
use btree_map::{BTreeMap, Keys, MoveEntries}; use btree_map::{BTreeMap, Keys};
use std::hash::Hash; use std::hash::Hash;
use core::borrow::BorrowFrom; use core::borrow::BorrowFrom;
use core::default::Default; use core::default::Default;
@ -33,37 +33,37 @@ pub struct BTreeSet<T>{
} }
/// An iterator over a BTreeSet's items. /// An iterator over a BTreeSet's items.
pub struct Items<'a, T: 'a> { pub struct Iter<'a, T: 'a> {
iter: Keys<'a, T, ()> iter: Keys<'a, T, ()>
} }
/// An owning iterator over a BTreeSet's items. /// 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> iter: Map<(T, ()), T, ::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>
} }
/// A lazy iterator producing elements in the set difference (in-order). /// A lazy iterator producing elements in the set difference (in-order).
pub struct DifferenceItems<'a, T:'a> { pub struct Difference<'a, T:'a> {
a: Peekable<&'a T, Items<'a, T>>, a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Items<'a, T>>, b: Peekable<&'a T, Iter<'a, T>>,
} }
/// A lazy iterator producing elements in the set symmetric difference (in-order). /// A lazy iterator producing elements in the set symmetric difference (in-order).
pub struct SymDifferenceItems<'a, T:'a> { pub struct SymmetricDifference<'a, T:'a> {
a: Peekable<&'a T, Items<'a, T>>, a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Items<'a, T>>, b: Peekable<&'a T, Iter<'a, T>>,
} }
/// A lazy iterator producing elements in the set intersection (in-order). /// A lazy iterator producing elements in the set intersection (in-order).
pub struct IntersectionItems<'a, T:'a> { pub struct Intersection<'a, T:'a> {
a: Peekable<&'a T, Items<'a, T>>, a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Items<'a, T>>, b: Peekable<&'a T, Iter<'a, T>>,
} }
/// A lazy iterator producing elements in the set union (in-order). /// A lazy iterator producing elements in the set union (in-order).
pub struct UnionItems<'a, T:'a> { pub struct Union<'a, T:'a> {
a: Peekable<&'a T, Items<'a, T>>, a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Items<'a, T>>, b: Peekable<&'a T, Iter<'a, T>>,
} }
impl<T: Ord> BTreeSet<T> { impl<T: Ord> BTreeSet<T> {
@ -107,8 +107,8 @@ impl<T> BTreeSet<T> {
/// assert_eq!(v, vec![1u,2,3,4]); /// assert_eq!(v, vec![1u,2,3,4]);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter<'a>(&'a self) -> Items<'a, T> { pub fn iter<'a>(&'a self) -> Iter<'a, T> {
Items { iter: self.map.keys() } Iter { iter: self.map.keys() }
} }
/// Gets an iterator for moving out the BtreeSet's contents. /// 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]); /// assert_eq!(v, vec![1u,2,3,4]);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[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 } 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) }
} }
} }
@ -151,8 +151,8 @@ impl<T: Ord> BTreeSet<T> {
/// assert_eq!(diff, vec![1u]); /// assert_eq!(diff, vec![1u]);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> DifferenceItems<'a, T> { pub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T> {
DifferenceItems{a: self.iter().peekable(), b: other.iter().peekable()} Difference{a: self.iter().peekable(), b: other.iter().peekable()}
} }
/// Visits the values representing the symmetric difference, in ascending order. /// Visits the values representing the symmetric difference, in ascending order.
@ -175,8 +175,8 @@ impl<T: Ord> BTreeSet<T> {
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet<T>) pub fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet<T>)
-> SymDifferenceItems<'a, T> { -> SymmetricDifference<'a, T> {
SymDifferenceItems{a: self.iter().peekable(), b: other.iter().peekable()} SymmetricDifference{a: self.iter().peekable(), b: other.iter().peekable()}
} }
/// Visits the values representing the intersection, in ascending order. /// Visits the values representing the intersection, in ascending order.
@ -199,8 +199,8 @@ impl<T: Ord> BTreeSet<T> {
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>)
-> IntersectionItems<'a, T> { -> Intersection<'a, T> {
IntersectionItems{a: self.iter().peekable(), b: other.iter().peekable()} Intersection{a: self.iter().peekable(), b: other.iter().peekable()}
} }
/// Visits the values representing the union, in ascending order. /// Visits the values representing the union, in ascending order.
@ -220,8 +220,8 @@ impl<T: Ord> BTreeSet<T> {
/// assert_eq!(union, vec![1u,2]); /// assert_eq!(union, vec![1u,2]);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn union<'a>(&'a self, other: &'a BTreeSet<T>) -> UnionItems<'a, T> { pub fn union<'a>(&'a self, other: &'a BTreeSet<T>) -> Union<'a, T> {
UnionItems{a: self.iter().peekable(), b: other.iter().peekable()} Union{a: self.iter().peekable(), b: other.iter().peekable()}
} }
/// Return the number of elements in the set /// Return the number of elements in the set
@ -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 next(&mut self) -> Option<&'a T> { self.iter.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } 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() } 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 next(&mut self) -> Option<T> { self.iter.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } 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() } 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 /// 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>, fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,
@ -573,7 +573,7 @@ fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,
} }
} }
impl<'a, T: Ord> Iterator<&'a T> for DifferenceItems<'a, T> { impl<'a, T: Ord> Iterator<&'a T> for Difference<'a, T> {
fn next(&mut self) -> Option<&'a T> { fn next(&mut self) -> Option<&'a T> {
loop { loop {
match cmp_opt(self.a.peek(), self.b.peek(), Less, Less) { match cmp_opt(self.a.peek(), self.b.peek(), Less, Less) {
@ -585,7 +585,7 @@ impl<'a, T: Ord> Iterator<&'a T> for DifferenceItems<'a, T> {
} }
} }
impl<'a, T: Ord> Iterator<&'a T> for SymDifferenceItems<'a, T> { impl<'a, T: Ord> Iterator<&'a T> for SymmetricDifference<'a, T> {
fn next(&mut self) -> Option<&'a T> { fn next(&mut self) -> Option<&'a T> {
loop { loop {
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) { match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
@ -597,7 +597,7 @@ impl<'a, T: Ord> Iterator<&'a T> for SymDifferenceItems<'a, T> {
} }
} }
impl<'a, T: Ord> Iterator<&'a T> for IntersectionItems<'a, T> { impl<'a, T: Ord> Iterator<&'a T> for Intersection<'a, T> {
fn next(&mut self) -> Option<&'a T> { fn next(&mut self) -> Option<&'a T> {
loop { loop {
let o_cmp = match (self.a.peek(), self.b.peek()) { let o_cmp = match (self.a.peek(), self.b.peek()) {
@ -615,7 +615,7 @@ impl<'a, T: Ord> Iterator<&'a T> for IntersectionItems<'a, T> {
} }
} }
impl<'a, T: Ord> Iterator<&'a T> for UnionItems<'a, T> { impl<'a, T: Ord> Iterator<&'a T> for Union<'a, T> {
fn next(&mut self) -> Option<&'a T> { fn next(&mut self) -> Option<&'a T> {
loop { loop {
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) { match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {

View File

@ -51,21 +51,21 @@ struct Node<T> {
} }
/// An iterator over references to the items of a `DList`. /// 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>, head: &'a Link<T>,
tail: Rawlink<Node<T>>, tail: Rawlink<Node<T>>,
nelem: uint, nelem: uint,
} }
// FIXME #11820: the &'a Option<> of the Link stops clone working. // FIXME #11820: the &'a Option<> of the Link stops clone working.
impl<'a, T> Clone for Items<'a, T> { impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Items<'a, T> { *self } 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`. /// 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>, list: &'a mut DList<T>,
head: Rawlink<Node<T>>, head: Rawlink<Node<T>>,
tail: 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`. /// An iterator over mutable references to the items of a `DList`.
#[deriving(Clone)] #[deriving(Clone)]
pub struct MoveItems<T> { pub struct IntoIter<T> {
list: DList<T> list: DList<T>
} }
@ -394,19 +394,19 @@ impl<T> DList<T> {
/// Provides a forward iterator. /// Provides a forward iterator.
#[inline] #[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter<'a>(&'a self) -> Items<'a, T> { pub fn iter<'a>(&'a self) -> Iter<'a, T> {
Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail} Iter{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
} }
/// Provides a forward iterator with mutable references. /// Provides a forward iterator with mutable references.
#[inline] #[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[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 { let head_raw = match self.list_head {
Some(ref mut h) => Rawlink::some(&mut **h), Some(ref mut h) => Rawlink::some(&mut **h),
None => Rawlink::none(), None => Rawlink::none(),
}; };
MutItems{ IterMut{
nelem: self.len(), nelem: self.len(),
head: head_raw, head: head_raw,
tail: self.list_tail, tail: self.list_tail,
@ -417,8 +417,8 @@ impl<T> DList<T> {
/// Consumes the list into an iterator yielding elements by value. /// Consumes the list into an iterator yielding elements by value.
#[inline] #[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveItems<T> { pub fn into_iter(self) -> IntoIter<T> {
MoveItems{list: self} IntoIter{list: self}
} }
/// Returns `true` if the `DList` is empty. /// 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] #[inline]
fn next(&mut self) -> Option<&'a A> { fn next(&mut self) -> Option<&'a A> {
if self.nelem == 0 { 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] #[inline]
fn next_back(&mut self) -> Option<&'a A> { fn next_back(&mut self) -> Option<&'a A> {
if self.nelem == 0 { 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] #[inline]
fn next(&mut self) -> Option<&'a mut A> { fn next(&mut self) -> Option<&'a mut A> {
if self.nelem == 0 { 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] #[inline]
fn next_back(&mut self) -> Option<&'a mut A> { fn next_back(&mut self) -> Option<&'a mut A> {
if self.nelem == 0 { 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. /// Allows mutating a `DList` while iterating.
pub trait ListInsertion<A> { pub trait ListInsertion<A> {
@ -664,8 +664,8 @@ pub trait ListInsertion<A> {
fn peek_next<'a>(&'a mut self) -> Option<&'a mut A>; fn peek_next<'a>(&'a mut self) -> Option<&'a mut A>;
} }
// private methods for MutItems // private methods for IterMut
impl<'a, A> MutItems<'a, A> { impl<'a, A> IterMut<'a, A> {
fn insert_next_node(&mut self, mut ins_node: Box<Node<A>>) { fn insert_next_node(&mut self, mut ins_node: Box<Node<A>>) {
// Insert before `self.head` so that it is between the // Insert before `self.head` so that it is between the
// previously yielded element and self.head. // 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] #[inline]
fn insert_next(&mut self, elt: A) { fn insert_next(&mut self, elt: A) {
self.insert_next_node(box Node::new(elt)) 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] #[inline]
fn next(&mut self) -> Option<A> { self.list.pop_front() } 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] #[inline]
fn next_back(&mut self) -> Option<A> { self.list.pop_back() } fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
} }

View File

@ -178,8 +178,8 @@ impl<E:CLike> EnumSet<E> {
/// Returns an iterator over an `EnumSet`. /// Returns an iterator over an `EnumSet`.
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter(&self) -> Items<E> { pub fn iter(&self) -> Iter<E> {
Items::new(self.bits) Iter::new(self.bits)
} }
} }
@ -208,18 +208,18 @@ impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
} }
/// An iterator over an EnumSet /// An iterator over an EnumSet
pub struct Items<E> { pub struct Iter<E> {
index: uint, index: uint,
bits: uint, bits: uint,
} }
impl<E:CLike> Items<E> { impl<E:CLike> Iter<E> {
fn new(bits: uint) -> Items<E> { fn new(bits: uint) -> Iter<E> {
Items { index: 0, bits: bits } 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> { fn next(&mut self) -> Option<E> {
if self.bits == 0 { if self.bits == 0 {
return None; return None;

View File

@ -377,8 +377,8 @@ impl<T> RingBuf<T> {
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b); /// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter(&self) -> Items<T> { pub fn iter(&self) -> Iter<T> {
Items { Iter {
tail: self.tail, tail: self.tail,
head: self.head, head: self.head,
ring: unsafe { self.buffer_as_slice() } ring: unsafe { self.buffer_as_slice() }
@ -403,8 +403,8 @@ impl<T> RingBuf<T> {
/// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b); /// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[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> {
MutItems { IterMut {
tail: self.tail, tail: self.tail,
head: self.head, head: self.head,
cap: self.cap, cap: self.cap,
@ -415,8 +415,8 @@ impl<T> RingBuf<T> {
/// Consumes the list into an iterator yielding elements by value. /// Consumes the list into an iterator yielding elements by value.
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveItems<T> { pub fn into_iter(self) -> IntoIter<T> {
MoveItems { IntoIter {
inner: self, inner: self,
} }
} }
@ -1123,13 +1123,13 @@ fn count(tail: uint, head: uint, size: uint) -> uint {
} }
/// `RingBuf` iterator. /// `RingBuf` iterator.
pub struct Items<'a, T:'a> { pub struct Iter<'a, T:'a> {
ring: &'a [T], ring: &'a [T],
tail: uint, tail: uint,
head: uint head: uint
} }
impl<'a, T> Iterator<&'a T> for Items<'a, T> { impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
#[inline] #[inline]
fn next(&mut self) -> Option<&'a T> { fn next(&mut self) -> Option<&'a T> {
if self.tail == self.head { if self.tail == self.head {
@ -1147,7 +1147,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] #[inline]
fn next_back(&mut self) -> Option<&'a T> { fn next_back(&mut self) -> Option<&'a T> {
if self.tail == self.head { if self.tail == self.head {
@ -1158,9 +1158,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] #[inline]
fn indexable(&self) -> uint { fn indexable(&self) -> uint {
let (len, _) = self.size_hint(); let (len, _) = self.size_hint();
@ -1178,11 +1178,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 // with returning the mutable reference. I couldn't find a way to
// make the lifetime checker happy so, but there should be a way. // make the lifetime checker happy so, but there should be a way.
/// `RingBuf` mutable iterator. /// `RingBuf` mutable iterator.
pub struct MutItems<'a, T:'a> { pub struct IterMut<'a, T:'a> {
ptr: *mut T, ptr: *mut T,
tail: uint, tail: uint,
head: uint, head: uint,
@ -1190,7 +1190,7 @@ pub struct MutItems<'a, T:'a> {
marker: marker::ContravariantLifetime<'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] #[inline]
fn next(&mut self) -> Option<&'a mut T> { fn next(&mut self) -> Option<&'a mut T> {
if self.tail == self.head { if self.tail == self.head {
@ -1211,7 +1211,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] #[inline]
fn next_back(&mut self) -> Option<&'a mut T> { fn next_back(&mut self) -> Option<&'a mut T> {
if self.tail == self.head { if self.tail == self.head {
@ -1225,14 +1225,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 // A by-value RingBuf iterator
pub struct MoveItems<T> { pub struct IntoIter<T> {
inner: RingBuf<T>, inner: RingBuf<T>,
} }
impl<T> Iterator<T> for MoveItems<T> { impl<T> Iterator<T> for IntoIter<T> {
#[inline] #[inline]
fn next(&mut self) -> Option<T> { fn next(&mut self) -> Option<T> {
self.inner.pop_front() self.inner.pop_front()
@ -1245,14 +1245,14 @@ impl<T> Iterator<T> for MoveItems<T> {
} }
} }
impl<T> DoubleEndedIterator<T> for MoveItems<T> { impl<T> DoubleEndedIterator<T> for IntoIter<T> {
#[inline] #[inline]
fn next_back(&mut self) -> Option<T> { fn next_back(&mut self) -> Option<T> {
self.inner.pop_back() self.inner.pop_back()
} }
} }
impl<T> ExactSizeIterator<T> for MoveItems<T> {} impl<T> ExactSizeIterator<T> for IntoIter<T> {}
/// A draining RingBuf iterator /// A draining RingBuf iterator
pub struct Drain<'a, T: 'a> { pub struct Drain<'a, T: 'a> {

View File

@ -37,7 +37,7 @@
//! //!
//! ## Structs //! ## 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. //! represents iteration over a slice.
//! //!
//! ## Traits //! ## Traits
@ -104,7 +104,7 @@ use self::Direction::*;
use vec::Vec; use vec::Vec;
pub use core::slice::{Chunks, AsSlice, SplitsN, Windows}; 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::{ImmutableIntSlice, MutableIntSlice};
pub use core::slice::{MutSplits, MutChunks, Splits}; pub use core::slice::{MutSplits, MutChunks, Splits};
pub use core::slice::{bytes, mut_ref_slice, ref_slice}; 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 /// Returns an iterator over the slice
#[unstable = "iterator type may change"] #[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 /// Returns an iterator over subslices separated by elements that match
/// `pred`. The matched element is not contained in the subslices. /// `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 /// Returns an iterator that allows modifying each value
#[unstable = "waiting on iterator type name conventions"] #[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 /// Returns a mutable pointer to the first element of a slice, or `None` if it is empty
#[unstable = "name may change"] #[unstable = "name may change"]
@ -1137,7 +1137,7 @@ impl<T> SliceExt<T> for [T] {
} }
#[inline] #[inline]
fn iter<'a>(&'a self) -> Items<'a, T> { fn iter<'a>(&'a self) -> Iter<'a, T> {
core_slice::SliceExt::iter(self) core_slice::SliceExt::iter(self)
} }
@ -1246,7 +1246,7 @@ impl<T> SliceExt<T> for [T] {
} }
#[inline] #[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) core_slice::SliceExt::iter_mut(self)
} }

View File

@ -888,7 +888,7 @@ impl<T> Vec<T> {
/// ``` /// ```
#[inline] #[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[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 { unsafe {
let ptr = self.ptr; let ptr = self.ptr;
let cap = self.cap; let cap = self.cap;
@ -899,7 +899,7 @@ impl<T> Vec<T> {
ptr.offset(self.len() as int) as *const T ptr.offset(self.len() as int) as *const T
}; };
mem::forget(self); 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. /// 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 allocation: *mut T, // the block of memory allocated for the vector
cap: uint, // the capacity of the vector cap: uint, // the capacity of the vector
ptr: *const T, ptr: *const T,
end: *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. /// Drops all items that have not yet been moved and returns the empty vector.
#[inline] #[inline]
#[unstable] #[unstable]
pub fn into_inner(mut self) -> Vec<T> { pub fn into_inner(mut self) -> Vec<T> {
unsafe { unsafe {
for _x in self { } 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); mem::forget(self);
Vec { ptr: allocation, cap: cap, len: 0 } Vec { ptr: allocation, cap: cap, len: 0 }
} }
@ -1427,7 +1427,7 @@ impl<T> MoveItems<T> {
pub fn unwrap(self) -> Vec<T> { self.into_inner() } pub fn unwrap(self) -> Vec<T> { self.into_inner() }
} }
impl<T> Iterator<T> for MoveItems<T> { impl<T> Iterator<T> for IntoIter<T> {
#[inline] #[inline]
fn next<'a>(&'a mut self) -> Option<T> { fn next<'a>(&'a mut self) -> Option<T> {
unsafe { 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] #[inline]
fn next_back<'a>(&'a mut self) -> Option<T> { fn next_back<'a>(&'a mut self) -> Option<T> {
unsafe { 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] #[unsafe_destructor]
impl<T> Drop for MoveItems<T> { impl<T> Drop for IntoIter<T> {
fn drop(&mut self) { fn drop(&mut self) {
// destroy the remaining elements // destroy the remaining elements
if self.cap != 0 { if self.cap != 0 {

View File

@ -176,8 +176,8 @@ impl<V> VecMap<V> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter<'r>(&'r self) -> Entries<'r, V> { pub fn iter<'r>(&'r self) -> Iter<'r, V> {
Entries { Iter {
front: 0, front: 0,
back: self.v.len(), back: self.v.len(),
iter: self.v.iter() iter: self.v.iter()
@ -207,8 +207,8 @@ impl<V> VecMap<V> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter_mut<'r>(&'r mut self) -> MutEntries<'r, V> { pub fn iter_mut<'r>(&'r mut self) -> IterMut<'r, V> {
MutEntries { IterMut {
front: 0, front: 0,
back: self.v.len(), back: self.v.len(),
iter: self.v.iter_mut() iter: self.v.iter_mut()
@ -235,13 +235,13 @@ impl<V> VecMap<V> {
/// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]);
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[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)> { fn filter<A>((i, v): (uint, Option<A>)) -> Option<(uint, A)> {
v.map(|v| (i, v)) v.map(|v| (i, v))
} }
let values = replace(&mut self.v, vec!()); 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. /// Return the number of elements in the map.
@ -605,42 +605,42 @@ macro_rules! double_ended_iterator {
} }
/// An iterator over the key-value pairs of a map. /// An iterator over the key-value pairs of a map.
pub struct Entries<'a, V:'a> { pub struct Iter<'a, V:'a> {
front: uint, front: uint,
back: uint, back: uint,
iter: slice::Items<'a, Option<V>> iter: slice::Iter<'a, Option<V>>
} }
iterator! { impl Entries -> (uint, &'a V), as_ref } iterator! { impl Iter -> (uint, &'a V), as_ref }
double_ended_iterator! { impl Entries -> (uint, &'a V), as_ref } double_ended_iterator! { impl Iter -> (uint, &'a V), as_ref }
/// An iterator over the key-value pairs of a map, with the /// An iterator over the key-value pairs of a map, with the
/// values being mutable. /// values being mutable.
pub struct MutEntries<'a, V:'a> { pub struct IterMut<'a, V:'a> {
front: uint, front: uint,
back: uint, back: uint,
iter: slice::MutItems<'a, Option<V>> iter: slice::IterMut<'a, Option<V>>
} }
iterator! { impl MutEntries -> (uint, &'a mut V), as_mut } iterator! { impl IterMut -> (uint, &'a mut V), as_mut }
double_ended_iterator! { impl MutEntries -> (uint, &'a mut V), as_mut } double_ended_iterator! { impl IterMut -> (uint, &'a mut V), as_mut }
/// An iterator over the keys of a map. /// An iterator over the keys of a map.
pub struct Keys<'a, V: 'a> { pub struct Keys<'a, V: 'a> {
iter: Map<(uint, &'a V), uint, Entries<'a, V>, fn((uint, &'a V)) -> uint> iter: Map<(uint, &'a V), uint, Iter<'a, V>, fn((uint, &'a V)) -> uint>
} }
/// An iterator over the values of a map. /// An iterator over the values of a map.
pub struct Values<'a, V: 'a> { pub struct Values<'a, V: 'a> {
iter: Map<(uint, &'a V), &'a V, Entries<'a, V>, fn((uint, &'a V)) -> &'a V> iter: Map<(uint, &'a V), &'a V, Iter<'a, V>, fn((uint, &'a V)) -> &'a V>
} }
/// A consuming iterator over the key-value pairs of a map. /// A consuming iterator over the key-value pairs of a map.
pub struct MoveItems<V> { pub struct IntoIter<V> {
iter: FilterMap< iter: FilterMap<
(uint, Option<V>), (uint, Option<V>),
(uint, V), (uint, V),
Enumerate<vec::MoveItems<Option<V>>>, Enumerate<vec::IntoIter<Option<V>>>,
fn((uint, Option<V>)) -> Option<(uint, 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 next(&mut self) -> Option<(uint, V)> { self.iter.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } 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() } fn next_back(&mut self) -> Option<(uint, V)> { self.iter.next_back() }
} }

View File

@ -89,7 +89,7 @@ pub struct Formatter<'a> {
precision: Option<uint>, precision: Option<uint>,
buf: &'a mut (FormatWriter+'a), buf: &'a mut (FormatWriter+'a),
curarg: slice::Items<'a, Argument<'a>>, curarg: slice::Iter<'a, Argument<'a>>,
args: &'a [Argument<'a>], args: &'a [Argument<'a>],
} }

View File

@ -67,7 +67,7 @@ pub trait SliceExt<T> for Sized? {
fn slice_from<'a>(&'a self, start: uint) -> &'a [T]; fn slice_from<'a>(&'a self, start: uint) -> &'a [T];
fn slice_to<'a>(&'a self, end: uint) -> &'a [T]; fn slice_to<'a>(&'a self, end: uint) -> &'a [T];
fn split_at<'a>(&'a self, mid: uint) -> (&'a [T], &'a [T]); fn split_at<'a>(&'a self, mid: uint) -> (&'a [T], &'a [T]);
fn iter<'a>(&'a self) -> Items<'a, T>; fn iter<'a>(&'a self) -> Iter<'a, T>;
fn split<'a, P>(&'a self, pred: P) -> Splits<'a, T, P> fn split<'a, P>(&'a self, pred: P) -> Splits<'a, T, P>
where P: FnMut(&T) -> bool; where P: FnMut(&T) -> bool;
fn splitn<'a, P>(&'a self, n: uint, pred: P) -> SplitsN<Splits<'a, T, P>> fn splitn<'a, P>(&'a self, n: uint, pred: P) -> SplitsN<Splits<'a, T, P>>
@ -92,7 +92,7 @@ pub trait SliceExt<T> for Sized? {
fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T]; fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T];
fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T]; fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T];
fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T]; fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T];
fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T>; fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>;
fn head_mut<'a>(&'a mut self) -> Option<&'a mut T>; fn head_mut<'a>(&'a mut self) -> Option<&'a mut T>;
fn tail_mut<'a>(&'a mut self) -> &'a mut [T]; fn tail_mut<'a>(&'a mut self) -> &'a mut [T];
fn init_mut<'a>(&'a mut self) -> &'a mut [T]; fn init_mut<'a>(&'a mut self) -> &'a mut [T];
@ -141,15 +141,15 @@ impl<T> SliceExt<T> for [T] {
} }
#[inline] #[inline]
fn iter<'a>(&'a self) -> Items<'a, T> { fn iter<'a>(&'a self) -> Iter<'a, T> {
unsafe { unsafe {
let p = self.as_ptr(); let p = self.as_ptr();
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
Items{ptr: p, Iter{ptr: p,
end: (p as uint + self.len()) as *const T, end: (p as uint + self.len()) as *const T,
marker: marker::ContravariantLifetime::<'a>} marker: marker::ContravariantLifetime::<'a>}
} else { } else {
Items{ptr: p, Iter{ptr: p,
end: p.offset(self.len() as int), end: p.offset(self.len() as int),
marker: marker::ContravariantLifetime::<'a>} marker: marker::ContravariantLifetime::<'a>}
} }
@ -286,15 +286,15 @@ impl<T> SliceExt<T> for [T] {
} }
#[inline] #[inline]
fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
unsafe { unsafe {
let p = self.as_mut_ptr(); let p = self.as_mut_ptr();
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
MutItems{ptr: p, IterMut{ptr: p,
end: (p as uint + self.len()) as *mut T, end: (p as uint + self.len()) as *mut T,
marker: marker::ContravariantLifetime::<'a>} marker: marker::ContravariantLifetime::<'a>}
} else { } else {
MutItems{ptr: p, IterMut{ptr: p,
end: p.offset(self.len() as int), end: p.offset(self.len() as int),
marker: marker::ContravariantLifetime::<'a>} marker: marker::ContravariantLifetime::<'a>}
} }
@ -655,7 +655,7 @@ impl<'a, T> Default for &'a [T] {
// Iterators // Iterators
// //
// The shared definition of the `Item` and `MutItems` iterators // The shared definition of the `Item` and `IterMut` iterators
macro_rules! iterator { macro_rules! iterator {
(struct $name:ident -> $ptr:ty, $elem:ty) => { (struct $name:ident -> $ptr:ty, $elem:ty) => {
#[experimental = "needs review"] #[experimental = "needs review"]
@ -738,14 +738,14 @@ macro_rules! make_slice {
/// Immutable slice iterator /// Immutable slice iterator
#[experimental = "needs review"] #[experimental = "needs review"]
pub struct Items<'a, T: 'a> { pub struct Iter<'a, T: 'a> {
ptr: *const T, ptr: *const T,
end: *const T, end: *const T,
marker: marker::ContravariantLifetime<'a> marker: marker::ContravariantLifetime<'a>
} }
#[experimental] #[experimental]
impl<'a, T> ops::Slice<uint, [T]> for Items<'a, T> { impl<'a, T> ops::Slice<uint, [T]> for Iter<'a, T> {
fn as_slice_(&self) -> &[T] { fn as_slice_(&self) -> &[T] {
self.as_slice() self.as_slice()
} }
@ -763,7 +763,7 @@ impl<'a, T> ops::Slice<uint, [T]> for Items<'a, T> {
} }
} }
impl<'a, T> Items<'a, T> { impl<'a, T> Iter<'a, T> {
/// View the underlying data as a subslice of the original data. /// View the underlying data as a subslice of the original data.
/// ///
/// This has the same lifetime as the original slice, and so the /// This has the same lifetime as the original slice, and so the
@ -774,20 +774,20 @@ impl<'a, T> Items<'a, T> {
} }
} }
impl<'a,T> Copy for Items<'a,T> {} impl<'a,T> Copy for Iter<'a,T> {}
iterator!{struct Items -> *const T, &'a T} iterator!{struct Iter -> *const T, &'a T}
#[experimental = "needs review"] #[experimental = "needs review"]
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {} impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}
#[stable] #[stable]
impl<'a, T> Clone for Items<'a, T> { impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Items<'a, T> { *self } fn clone(&self) -> Iter<'a, T> { *self }
} }
#[experimental = "needs review"] #[experimental = "needs review"]
impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> {
#[inline] #[inline]
fn indexable(&self) -> uint { fn indexable(&self) -> uint {
let (exact, _) = self.size_hint(); let (exact, _) = self.size_hint();
@ -813,14 +813,14 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
/// Mutable slice iterator. /// Mutable slice iterator.
#[experimental = "needs review"] #[experimental = "needs review"]
pub struct MutItems<'a, T: 'a> { pub struct IterMut<'a, T: 'a> {
ptr: *mut T, ptr: *mut T,
end: *mut T, end: *mut T,
marker: marker::ContravariantLifetime<'a>, marker: marker::ContravariantLifetime<'a>,
} }
#[experimental] #[experimental]
impl<'a, T> ops::Slice<uint, [T]> for MutItems<'a, T> { impl<'a, T> ops::Slice<uint, [T]> for IterMut<'a, T> {
fn as_slice_<'b>(&'b self) -> &'b [T] { fn as_slice_<'b>(&'b self) -> &'b [T] {
make_slice!(T -> &'b [T]: self.ptr, self.end) make_slice!(T -> &'b [T]: self.ptr, self.end)
} }
@ -839,7 +839,7 @@ impl<'a, T> ops::Slice<uint, [T]> for MutItems<'a, T> {
} }
#[experimental] #[experimental]
impl<'a, T> ops::SliceMut<uint, [T]> for MutItems<'a, T> { impl<'a, T> ops::SliceMut<uint, [T]> for IterMut<'a, T> {
fn as_mut_slice_<'b>(&'b mut self) -> &'b mut [T] { fn as_mut_slice_<'b>(&'b mut self) -> &'b mut [T] {
make_slice!(T -> &'b mut [T]: self.ptr, self.end) make_slice!(T -> &'b mut [T]: self.ptr, self.end)
} }
@ -857,7 +857,7 @@ impl<'a, T> ops::SliceMut<uint, [T]> for MutItems<'a, T> {
} }
} }
impl<'a, T> MutItems<'a, T> { impl<'a, T> IterMut<'a, T> {
/// View the underlying data as a subslice of the original data. /// View the underlying data as a subslice of the original data.
/// ///
/// To avoid creating `&mut` references that alias, this is forced /// To avoid creating `&mut` references that alias, this is forced
@ -870,10 +870,10 @@ impl<'a, T> MutItems<'a, T> {
} }
} }
iterator!{struct MutItems -> *mut T, &'a mut T} iterator!{struct IterMut -> *mut T, &'a mut T}
#[experimental = "needs review"] #[experimental = "needs review"]
impl<'a, T> ExactSizeIterator<&'a mut T> for MutItems<'a, T> {} impl<'a, T> ExactSizeIterator<&'a mut T> for IterMut<'a, T> {}
/// An abstraction over the splitting iterators, so that splitn, splitn_mut etc /// An abstraction over the splitting iterators, so that splitn, splitn_mut etc
/// can be implemented once. /// can be implemented once.

View File

@ -185,7 +185,7 @@ Section: Iterators
/// Created with the method `.chars()`. /// Created with the method `.chars()`.
#[deriving(Clone, Copy)] #[deriving(Clone, Copy)]
pub struct Chars<'a> { pub struct Chars<'a> {
iter: slice::Items<'a, u8> iter: slice::Iter<'a, u8>
} }
// Return the initial codepoint accumulator for the first byte. // Return the initial codepoint accumulator for the first byte.
@ -866,7 +866,7 @@ Section: Misc
/// `iter` reset such that it is pointing at the first byte in the /// `iter` reset such that it is pointing at the first byte in the
/// invalid sequence. /// invalid sequence.
#[inline(always)] #[inline(always)]
fn run_utf8_validation_iterator(iter: &mut slice::Items<u8>) fn run_utf8_validation_iterator(iter: &mut slice::Iter<u8>)
-> Result<(), Utf8Error> { -> Result<(), Utf8Error> {
let whole = iter.as_slice(); let whole = iter.as_slice();
loop { loop {
@ -1575,7 +1575,6 @@ impl<'a> Default for &'a str {
fn default() -> &'a str { "" } fn default() -> &'a str { "" }
} }
impl<'a> Iterator<&'a str> for Lines<'a> { impl<'a> Iterator<&'a str> for Lines<'a> {
#[inline] #[inline]
fn next(&mut self) -> Option<&'a str> { self.inner.next() } fn next(&mut self) -> Option<&'a str> { self.inner.next() }

View File

@ -63,7 +63,7 @@ impl<'a,T> IntoMaybeOwnedVector<'a,T> for &'a [T] {
} }
impl<'a,T> MaybeOwnedVector<'a,T> { impl<'a,T> MaybeOwnedVector<'a,T> {
pub fn iter(&'a self) -> slice::Items<'a,T> { pub fn iter(&'a self) -> slice::Iter<'a,T> {
match self { match self {
&Growable(ref v) => v.as_slice().iter(), &Growable(ref v) => v.as_slice().iter(),
&Borrowed(ref v) => v.iter(), &Borrowed(ref v) => v.iter(),

View File

@ -370,7 +370,7 @@ pub fn mod_enabled(level: u32, module: &str) -> bool {
fn enabled(level: u32, fn enabled(level: u32,
module: &str, module: &str,
iter: slice::Items<directive::LogDirective>) iter: slice::Iter<directive::LogDirective>)
-> bool { -> bool {
// Search for the longest match, the vector is assumed to be pre-sorted. // Search for the longest match, the vector is assumed to be pre-sorted.
for directive in iter.rev() { for directive in iter.rev() {

View File

@ -540,8 +540,8 @@ impl Regex {
} }
pub enum NamesIter<'a> { pub enum NamesIter<'a> {
NamesIterNative(::std::slice::Items<'a, Option<&'static str>>), NamesIterNative(::std::slice::Iter<'a, Option<&'static str>>),
NamesIterDynamic(::std::slice::Items<'a, Option<String>>) NamesIterDynamic(::std::slice::Iter<'a, Option<String>>)
} }
impl<'a> Iterator<Option<String>> for NamesIter<'a> { impl<'a> Iterator<Option<String>> for NamesIter<'a> {

View File

@ -65,7 +65,7 @@ impl LanguageItems {
} }
} }
pub fn items<'a>(&'a self) -> Enumerate<slice::Items<'a, Option<ast::DefId>>> { pub fn items<'a>(&'a self) -> Enumerate<slice::Iter<'a, Option<ast::DefId>>> {
self.items.iter().enumerate() self.items.iter().enumerate()
} }

View File

@ -18,7 +18,7 @@ use middle::ty_fold::{mod, TypeFoldable, TypeFolder};
use util::ppaux::Repr; use util::ppaux::Repr;
use std::fmt; use std::fmt;
use std::slice::Items; use std::slice::Iter;
use std::vec::Vec; use std::vec::Vec;
use syntax::codemap::{Span, DUMMY_SP}; use syntax::codemap::{Span, DUMMY_SP};
@ -400,7 +400,7 @@ impl<T> VecPerParamSpace<T> {
&self.get_slice(space)[index] &self.get_slice(space)[index]
} }
pub fn iter<'a>(&'a self) -> Items<'a,T> { pub fn iter<'a>(&'a self) -> Iter<'a,T> {
self.content.iter() self.content.iter()
} }

View File

@ -19,7 +19,7 @@ use middle::subst;
use middle::ty::{mod, Ty}; use middle::ty::{mod, Ty};
use middle::infer::InferCtxt; use middle::infer::InferCtxt;
use std::rc::Rc; use std::rc::Rc;
use std::slice::Items; use std::slice::Iter;
use syntax::ast; use syntax::ast;
use syntax::codemap::{Span, DUMMY_SP}; use syntax::codemap::{Span, DUMMY_SP};
@ -304,7 +304,7 @@ impl<'tcx> ObligationCause<'tcx> {
} }
impl<'tcx, N> Vtable<'tcx, N> { impl<'tcx, N> Vtable<'tcx, N> {
pub fn iter_nested(&self) -> Items<N> { pub fn iter_nested(&self) -> Iter<N> {
match *self { match *self {
VtableImpl(ref i) => i.iter_nested(), VtableImpl(ref i) => i.iter_nested(),
VtableFnPointer(..) => (&[]).iter(), VtableFnPointer(..) => (&[]).iter(),
@ -338,7 +338,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
} }
impl<'tcx, N> VtableImplData<'tcx, N> { impl<'tcx, N> VtableImplData<'tcx, N> {
pub fn iter_nested(&self) -> Items<N> { pub fn iter_nested(&self) -> Iter<N> {
self.nested.iter() self.nested.iter()
} }
@ -365,7 +365,7 @@ impl<'tcx, N> VtableImplData<'tcx, N> {
} }
impl<N> VtableBuiltinData<N> { impl<N> VtableBuiltinData<N> {
pub fn iter_nested(&self) -> Items<N> { pub fn iter_nested(&self) -> Iter<N> {
self.nested.iter() self.nested.iter()
} }

View File

@ -914,8 +914,8 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// } /// }
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter_mut(&mut self) -> MutEntries<K, V> { pub fn iter_mut(&mut self) -> IterMut<K, V> {
MutEntries { inner: self.table.iter_mut() } IterMut { inner: self.table.iter_mut() }
} }
/// Creates a consuming iterator, that is, one that moves each key-value /// Creates a consuming iterator, that is, one that moves each key-value
@ -936,10 +936,10 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// let vec: Vec<(&str, int)> = map.into_iter().collect(); /// let vec: Vec<(&str, int)> = map.into_iter().collect();
/// ``` /// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"] #[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveEntries<K, V> { pub fn into_iter(self) -> IntoIter<K, V> {
fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) } fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
MoveEntries { IntoIter {
inner: self.table.into_iter().map(last_two) inner: self.table.into_iter().map(last_two)
} }
} }
@ -1306,16 +1306,16 @@ pub struct Entries<'a, K: 'a, V: 'a> {
} }
/// HashMap mutable values iterator /// HashMap mutable values iterator
pub struct MutEntries<'a, K: 'a, V: 'a> { pub struct IterMut<'a, K: 'a, V: 'a> {
inner: table::MutEntries<'a, K, V> inner: table::IterMut<'a, K, V>
} }
/// HashMap move iterator /// HashMap move iterator
pub struct MoveEntries<K, V> { pub struct IntoIter<K, V> {
inner: iter::Map< inner: iter::Map<
(SafeHash, K, V), (SafeHash, K, V),
(K, V), (K, V),
table::MoveEntries<K, V>, table::IntoIter<K, V>,
fn((SafeHash, K, V)) -> (K, V), fn((SafeHash, K, V)) -> (K, V),
> >
} }
@ -1374,12 +1374,12 @@ impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } #[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }
impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> { impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
#[inline] fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() } #[inline] fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() }
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } #[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }
impl<K, V> Iterator<(K, V)> for MoveEntries<K, V> { impl<K, V> Iterator<(K, V)> for IntoIter<K, V> {
#[inline] fn next(&mut self) -> Option<(K, V)> { self.inner.next() } #[inline] fn next(&mut self) -> Option<(K, V)> { self.inner.next() }
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() } #[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
} }

View File

@ -23,7 +23,7 @@ use ops::{BitOr, BitAnd, BitXor, Sub};
use option::Option::{Some, None, mod}; use option::Option::{Some, None, mod};
use result::Result::{Ok, Err}; use result::Result::{Ok, Err};
use super::map::{mod, HashMap, MoveEntries, Keys, INITIAL_CAPACITY}; use super::map::{mod, HashMap, Keys, INITIAL_CAPACITY};
// Future Optimization (FIXME!) // Future Optimization (FIXME!)
// ============================= // =============================
@ -736,7 +736,7 @@ pub struct Iter<'a, K: 'a> {
/// HashSet move iterator /// HashSet move iterator
pub struct IntoIter<K> { pub struct IntoIter<K> {
iter: Map<(K, ()), K, MoveEntries<K, ()>, fn((K, ())) -> K> iter: Map<(K, ()), K, map::IntoIter<K, ()>, fn((K, ())) -> K>
} }
/// HashSet drain iterator /// HashSet drain iterator

View File

@ -664,17 +664,17 @@ impl<K, V> RawTable<K, V> {
} }
} }
pub fn iter_mut(&mut self) -> MutEntries<K, V> { pub fn iter_mut(&mut self) -> IterMut<K, V> {
MutEntries { IterMut {
iter: self.raw_buckets(), iter: self.raw_buckets(),
elems_left: self.size(), elems_left: self.size(),
} }
} }
pub fn into_iter(self) -> MoveEntries<K, V> { pub fn into_iter(self) -> IntoIter<K, V> {
let RawBuckets { raw, hashes_end, .. } = self.raw_buckets(); let RawBuckets { raw, hashes_end, .. } = self.raw_buckets();
// Replace the marker regardless of lifetime bounds on parameters. // Replace the marker regardless of lifetime bounds on parameters.
MoveEntries { IntoIter {
iter: RawBuckets { iter: RawBuckets {
raw: raw, raw: raw,
hashes_end: hashes_end, hashes_end: hashes_end,
@ -776,13 +776,13 @@ pub struct Entries<'a, K: 'a, V: 'a> {
} }
/// Iterator over mutable references to entries in a table. /// Iterator over mutable references to entries in a table.
pub struct MutEntries<'a, K: 'a, V: 'a> { pub struct IterMut<'a, K: 'a, V: 'a> {
iter: RawBuckets<'a, K, V>, iter: RawBuckets<'a, K, V>,
elems_left: uint, elems_left: uint,
} }
/// Iterator over the entries in a table, consuming the table. /// Iterator over the entries in a table, consuming the table.
pub struct MoveEntries<K, V> { pub struct IntoIter<K, V> {
table: RawTable<K, V>, table: RawTable<K, V>,
iter: RawBuckets<'static, K, V> iter: RawBuckets<'static, K, V>
} }
@ -809,7 +809,7 @@ impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
} }
} }
impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> { impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a mut V)> { fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
self.iter.next().map(|bucket| { self.iter.next().map(|bucket| {
self.elems_left -= 1; self.elems_left -= 1;
@ -825,7 +825,7 @@ impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
} }
} }
impl<K, V> Iterator<(SafeHash, K, V)> for MoveEntries<K, V> { impl<K, V> Iterator<(SafeHash, K, V)> for IntoIter<K, V> {
fn next(&mut self) -> Option<(SafeHash, K, V)> { fn next(&mut self) -> Option<(SafeHash, K, V)> {
self.iter.next().map(|bucket| { self.iter.next().map(|bucket| {
self.table.size -= 1; self.table.size -= 1;

View File

@ -73,9 +73,9 @@ impl<'a> Iterator<PathElem> for LinkedPath<'a> {
} }
} }
// HACK(eddyb) move this into libstd (value wrapper for slice::Items). // HACK(eddyb) move this into libstd (value wrapper for slice::Iter).
#[deriving(Clone)] #[deriving(Clone)]
pub struct Values<'a, T:'a>(pub slice::Items<'a, T>); pub struct Values<'a, T:'a>(pub slice::Iter<'a, T>);
impl<'a, T: Copy> Iterator<T> for Values<'a, T> { impl<'a, T: Copy> Iterator<T> for Values<'a, T> {
fn next(&mut self) -> Option<T> { fn next(&mut self) -> Option<T> {

View File

@ -766,7 +766,7 @@ impl<'a> MethodDef<'a> {
let fields = if raw_fields.len() > 0 { let fields = if raw_fields.len() > 0 {
let mut raw_fields = raw_fields.into_iter().map(|v| v.into_iter()); let mut raw_fields = raw_fields.into_iter().map(|v| v.into_iter());
let first_field = raw_fields.next().unwrap(); let first_field = raw_fields.next().unwrap();
let mut other_fields: Vec<vec::MoveItems<(Span, Option<Ident>, P<Expr>)>> let mut other_fields: Vec<vec::IntoIter<(Span, Option<Ident>, P<Expr>)>>
= raw_fields.collect(); = raw_fields.collect();
first_field.map(|(span, opt_id, field)| { first_field.map(|(span, opt_id, field)| {
FieldInfo { FieldInfo {

View File

@ -45,7 +45,7 @@ impl<T> OwnedSlice<T> {
&*self.data &*self.data
} }
pub fn move_iter(self) -> vec::MoveItems<T> { pub fn move_iter(self) -> vec::IntoIter<T> {
self.into_vec().into_iter() self.into_vec().into_iter()
} }

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use self::SmallVectorRepr::*; use self::SmallVectorRepr::*;
use self::MoveItemsRepr::*; use self::IntoIterRepr::*;
use std::mem; use std::mem;
use std::slice; use std::slice;
@ -111,17 +111,17 @@ impl<T> SmallVector<T> {
/// Deprecated: use `into_iter`. /// Deprecated: use `into_iter`.
#[deprecated = "use into_iter"] #[deprecated = "use into_iter"]
pub fn move_iter(self) -> MoveItems<T> { pub fn move_iter(self) -> IntoIter<T> {
self.into_iter() self.into_iter()
} }
pub fn into_iter(self) -> MoveItems<T> { pub fn into_iter(self) -> IntoIter<T> {
let repr = match self.repr { let repr = match self.repr {
Zero => ZeroIterator, Zero => ZeroIterator,
One(v) => OneIterator(v), One(v) => OneIterator(v),
Many(vs) => ManyIterator(vs.into_iter()) Many(vs) => ManyIterator(vs.into_iter())
}; };
MoveItems { repr: repr } IntoIter { repr: repr }
} }
pub fn len(&self) -> uint { pub fn len(&self) -> uint {
@ -135,17 +135,17 @@ impl<T> SmallVector<T> {
pub fn is_empty(&self) -> bool { self.len() == 0 } pub fn is_empty(&self) -> bool { self.len() == 0 }
} }
pub struct MoveItems<T> { pub struct IntoIter<T> {
repr: MoveItemsRepr<T>, repr: IntoIterRepr<T>,
} }
enum MoveItemsRepr<T> { enum IntoIterRepr<T> {
ZeroIterator, ZeroIterator,
OneIterator(T), OneIterator(T),
ManyIterator(vec::MoveItems<T>), ManyIterator(vec::IntoIter<T>),
} }
impl<T> Iterator<T> for MoveItems<T> { impl<T> Iterator<T> for IntoIter<T> {
fn next(&mut self) -> Option<T> { fn next(&mut self) -> Option<T> {
match self.repr { match self.repr {
ZeroIterator => None, ZeroIterator => None,

View File

@ -130,7 +130,7 @@ struct Table {
struct Items<'a> { struct Items<'a> {
cur: Option<&'a Entry>, cur: Option<&'a Entry>,
items: slice::Items<'a, Option<Box<Entry>>>, items: slice::Iter<'a, Option<Box<Entry>>>,
} }
impl Table { impl Table {

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use std::slice::Items; use std::slice::Iter;
//~^ ERROR import `Items` conflicts with type in this module //~^ ERROR import `Iter` conflicts with type in this module
struct Items; struct Iter;
fn main() { fn main() {
} }

View File

@ -11,7 +11,7 @@
use std::slice; use std::slice;
pub struct PhfMapEntries<'a, T: 'a> { pub struct PhfMapEntries<'a, T: 'a> {
iter: slice::Items<'a, (&'static str, T)>, iter: slice::Iter<'a, (&'static str, T)>,
} }
impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> { impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> {