Change:
cc I'm in the process of -ifying the collections, and I've discovered that the takes a instead of the convention of consuming the value. It's also marked stable, even though the type itself is marked unstable. Should this instead be a candidate for the method discussed in the collection reform trait?
Yeah this is just a mistake. Feel free to fix it to match conventions.
Just to be clear, the solution to this is to make consume the value and introduce a function (and iterator). Is this right or am I missing something?
Yep!

Discussion:
} } <del> /// Returns an iterator visiting all keys in ascending order by the keys. </del> <ins> /// Returns an iterator visiting all keys in ascending order of the keys. </ins> /// The iterator's element type is `uint`. #[stable] pub fn keys<'r>(&'r self) -> Keys<'r, V> {

Keys { iter: self.iter().map(first) } } <del> /// Returns an iterator visiting all values in ascending order by the keys. </del> <ins> /// Returns an iterator visiting all values in ascending order of the keys. </ins> /// The iterator's element type is `&'r V`. #[stable] pub fn values<'r>(&'r self) -> Values<'r, V> {

Values { iter: self.iter().map(second) } } <del> /// Returns an iterator visiting all key-value pairs in ascending order by the keys. </del> <ins> /// Returns an iterator visiting all key-value pairs in ascending order of the keys. </ins> /// The iterator's element type is `(uint, &'r V)`. /// /// # Examples

} } <del> /// Returns an iterator visiting all key-value pairs in ascending order by the keys, </del> <ins> /// Returns an iterator visiting all key-value pairs in ascending order of the keys, </ins> /// with mutable references to the values. /// The iterator's element type is `(uint, &'r mut V)`. ///

} } <del> /// Returns an iterator visiting all key-value pairs in ascending order by /// the keys, emptying (but not consuming) the original `VecMap`. </del> <ins> /// Returns an iterator visiting all key-value pairs in ascending order of /// the keys, consuming the original `VecMap`. </ins> /// The iterator's element type is `(uint, &'r V)`. /// /// # Examples

/// map.insert(3, "c"); /// map.insert(2, "b"); /// <del> /// // Not possible with .iter() </del> /// let vec: Vec<(uint, &str)> = map.into_iter().collect(); /// /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` #[stable] <del> pub fn into_iter(&mut self) -> IntoIter<V> { </del> <ins> pub fn into_iter(self) -> IntoIter<V> { fn filter<A>((i, v): (uint, Option<A>)) -> Option<(uint, A)> { v.map(|v| (i, v)) } let filter: fn((uint, Option<V>)) -> Option<(uint, V)> = filter; // coerce to fn ptr IntoIter { iter: self.v.into_iter().enumerate().filter_map(filter) } } /// Returns an iterator visiting all key-value pairs in ascending order of /// the keys, emptying (but not consuming) the original `VecMap`. /// The iterator's element type is `(uint, &'r V)`. Keeps the allocated memory for reuse. /// /// # Examples /// /// ``` /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); /// map.insert(1, "a"); /// map.insert(3, "c"); /// map.insert(2, "b"); /// /// let vec: Vec<(uint, &str)> = map.drain().collect(); /// /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` #[unstable = "matches collection reform specification, waiting for dust to settle"] pub fn drain<'a>(&'a mut self) -> Drain<'a, V> { </ins> fn filter<A>((i, v): (uint, Option<A>)) -> Option<(uint, A)> { v.map(|v| (i, v)) } let filter: fn((uint, Option<V>)) -> Option<(uint, V)> = filter; // coerce to fn ptr <del> let values = replace(&mut self.v, vec!()); IntoIter { iter: values.into_iter().enumerate().filter_map(filter) } </del> <ins> Drain { iter: self.v.drain().enumerate().filter_map(filter) } </ins> } /// Return the number of elements in the map.

fn((uint, Option<V>)) -> Option<(uint, V)>> } <ins> #[unstable] pub struct Drain<'a, V> { iter: FilterMap< (uint, Option<V>), (uint, V), Enumerate<vec::Drain<'a, Option<V>>>, fn((uint, Option<V>)) -> Option<(uint, V)>> } #[unstable] impl<'a, V> Iterator for Drain<'a, V> { type Item = (uint, V); fn next(&mut self) -> Option<(uint, V)> { self.iter.next() } fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } } #[unstable] impl<'a, V> DoubleEndedIterator for Drain<'a, V> { fn next_back(&mut self) -> Option<(uint, V)> { self.iter.next_back() } } </ins> #[stable] impl<'a, V> Iterator for Keys<'a, V> { type Item = uint;

assert_eq!(v, box 2i); } assert!(called); <del> m.insert(2, box 1i); </del> <ins> } #[test] fn test_drain_iterator() { let mut map = VecMap::new(); map.insert(1, "a"); map.insert(3, "c"); map.insert(2, "b"); let vec: Vec<(usize, &str)> = map.drain().collect(); assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); assert_eq!(map.len(), 0); </ins> } #[test]