]> git.lizzy.rs Git - rust.git/blobdiff - src/libcollections/smallintmap.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.git] / src / libcollections / smallintmap.rs
index b3b3bb1ea22434ba8086842742d621c30c20d906..31d3415ef48934fa00a795b814ec2415f62b5c3d 100644 (file)
@@ -163,7 +163,7 @@ fn clone(&self) -> SmallIntMap<V> {
     #[inline]
     fn clone_from(&mut self, source: &SmallIntMap<V>) {
         self.v.reserve(source.v.len());
-        for (i, w) in self.v.mut_iter().enumerate() {
+        for (i, w) in self.v.iter_mut().enumerate() {
             *w = source.v[i].clone();
         }
     }
@@ -260,6 +260,12 @@ pub fn iter<'r>(&'r self) -> Entries<'r, V> {
         }
     }
 
+    /// Deprecated: use `iter_mut`
+    #[deprecated = "use iter_mut"]
+    pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> {
+        self.iter_mut()
+    }
+
     /// Returns an iterator visiting all key-value pairs in ascending order by the keys,
     /// with mutable references to the values.
     /// The iterator's element type is `(uint, &'r mut V)`.
@@ -274,7 +280,7 @@ pub fn iter<'r>(&'r self) -> Entries<'r, V> {
     /// map.insert(2, "b");
     /// map.insert(3, "c");
     ///
-    /// for (key, value) in map.mut_iter() {
+    /// for (key, value) in map.iter_mut() {
     ///     *value = "x";
     /// }
     ///
@@ -282,14 +288,22 @@ pub fn iter<'r>(&'r self) -> Entries<'r, V> {
     ///     assert_eq!(value, &"x");
     /// }
     /// ```
-    pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> {
+    pub fn iter_mut<'r>(&'r mut self) -> MutEntries<'r, V> {
         MutEntries {
             front: 0,
             back: self.v.len(),
-            iter: self.v.mut_iter()
+            iter: self.v.iter_mut()
         }
     }
 
+    /// Deprecated: use `into_iter` instead.
+    #[deprecated = "use into_iter"]
+    pub fn move_iter(&mut self)
+        -> FilterMap<(uint, Option<V>), (uint, V),
+                Enumerate<vec::MoveItems<Option<V>>>> {
+        self.into_iter()
+    }
+
     /// Returns an iterator visiting all key-value pairs in ascending order by
     /// the keys, emptying (but not consuming) the original `SmallIntMap`.
     /// The iterator's element type is `(uint, &'r V)`.
@@ -305,16 +319,16 @@ pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> {
     /// map.insert(2, "b");
     ///
     /// // Not possible with .iter()
-    /// let vec: Vec<(uint, &str)> = map.move_iter().collect();
+    /// let vec: Vec<(uint, &str)> = map.into_iter().collect();
     ///
     /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]);
     /// ```
-    pub fn move_iter(&mut self)
+    pub fn into_iter(&mut self)
         -> FilterMap<(uint, Option<V>), (uint, V),
                 Enumerate<vec::MoveItems<Option<V>>>>
     {
         let values = replace(&mut self.v, vec!());
-        values.move_iter().enumerate().filter_map(|(i, v)| {
+        values.into_iter().enumerate().filter_map(|(i, v)| {
             v.map(|v| (i, v))
         })
     }
@@ -324,7 +338,7 @@ impl<V:Clone> SmallIntMap<V> {
     /// Updates a value in the map. If the key already exists in the map,
     /// modifies the value with `ff` taking `oldval, newval`.
     /// Otherwise, sets the value to `newval`.
-    /// Returasn `true` if the key did not already exist in the map.
+    /// Returns `true` if the key did not already exist in the map.
     ///
     /// # Example
     ///
@@ -678,8 +692,8 @@ fn test_iterator_size_hints() {
 
         assert_eq!(m.iter().size_hint(), (0, Some(11)));
         assert_eq!(m.iter().rev().size_hint(), (0, Some(11)));
-        assert_eq!(m.mut_iter().size_hint(), (0, Some(11)));
-        assert_eq!(m.mut_iter().rev().size_hint(), (0, Some(11)));
+        assert_eq!(m.iter_mut().size_hint(), (0, Some(11)));
+        assert_eq!(m.iter_mut().rev().size_hint(), (0, Some(11)));
     }
 
     #[test]
@@ -692,7 +706,7 @@ fn test_mut_iterator() {
         assert!(m.insert(6, 10));
         assert!(m.insert(10, 11));
 
-        for (k, v) in m.mut_iter() {
+        for (k, v) in m.iter_mut() {
             *v += k as int;
         }
 
@@ -734,7 +748,7 @@ fn test_mut_rev_iterator() {
         assert!(m.insert(6, 10));
         assert!(m.insert(10, 11));
 
-        for (k, v) in m.mut_iter().rev() {
+        for (k, v) in m.iter_mut().rev() {
             *v += k as int;
         }
 
@@ -752,7 +766,7 @@ fn test_move_iter() {
         let mut m = SmallIntMap::new();
         m.insert(1, box 2i);
         let mut called = false;
-        for (k, v) in m.move_iter() {
+        for (k, v) in m.into_iter() {
             assert!(!called);
             called = true;
             assert_eq!(k, 1);