diff options
| author | Adolfo OchagavĂa <aochagavia92@gmail.com> | 2015-01-19 10:48:01 +0100 |
|---|---|---|
| committer | Adolfo OchagavĂa <aochagavia92@gmail.com> | 2015-01-19 10:48:01 +0100 |
| commit | 2366dee8e9cb41d963900c8d5128f810a87fc6bb (patch) | |
| tree | 54ddce9149c5d85014ccc5dc5f02e0e27b9c6f56 | |
| parent | bd8a43c668ba93d29e9671c0c8dc6b67428bf492 (diff) | |
| download | rust-2366dee8e9cb41d963900c8d5128f810a87fc6bb.tar.gz rust-2366dee8e9cb41d963900c8d5128f810a87fc6bb.zip | |
Make VecMap::into_iter consume the VecMap
This is a breaking change. To fix it you should pass the VecMap by value instead of by reference. [breaking-change]
| -rw-r--r-- | src/libcollections/vec_map.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index d4ce266d3e2..94ae1bece86 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -265,7 +265,7 @@ impl<V> VecMap<V> { } /// 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<V> VecMap<V> { /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` #[stable] - pub fn into_iter(&mut self) -> IntoIter<V> { + 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 - 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. |
