diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index d4ce266d3e211..94ae1bece86f7 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -265,7 +265,7 @@ impl VecMap { } /// Returns an iterator visiting all key-value pairs in ascending order by - /// the keys, emptying (but not consuming) the original `VecMap`. + /// the keys, consuming the original `VecMap`. /// The iterator's element type is `(uint, &'r V)`. /// /// # Examples @@ -284,14 +284,13 @@ impl VecMap { /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` #[stable] - pub fn into_iter(&mut self) -> IntoIter { + pub fn into_iter(self) -> IntoIter { fn filter((i, v): (uint, Option)) -> Option<(uint, A)> { v.map(|v| (i, v)) } let filter: fn((uint, Option)) -> Option<(uint, V)> = filter; // coerce to fn ptr - let values = replace(&mut self.v, vec!()); - IntoIter { iter: values.into_iter().enumerate().filter_map(filter) } + IntoIter { iter: self.v.into_iter().enumerate().filter_map(filter) } } /// Return the number of elements in the map.