@@ -1058,6 +1058,24 @@ impl<K, V> BTreeMap<K, V> {
1058
1058
}
1059
1059
1060
1060
/// Gets a mutable iterator over the entries of the map.
1061
+ ///
1062
+ /// # Examples
1063
+ ///
1064
+ /// ```
1065
+ /// use std::collections::BTreeMap;
1066
+ ///
1067
+ /// let mut map = BTreeMap::new();
1068
+ /// map.insert("a", 1u);
1069
+ /// map.insert("b", 2u);
1070
+ /// map.insert("c", 3u);
1071
+ ///
1072
+ /// // add 10 to the value if the key isn't "a"
1073
+ /// for (key, value) in map.iter_mut() {
1074
+ /// if key != &"a" {
1075
+ /// *value += 10;
1076
+ /// }
1077
+ /// }
1078
+ /// ```
1061
1079
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1062
1080
pub fn iter_mut < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
1063
1081
let len = self . len ( ) ;
@@ -1072,6 +1090,21 @@ impl<K, V> BTreeMap<K, V> {
1072
1090
}
1073
1091
1074
1092
/// Gets an owning iterator over the entries of the map.
1093
+ ///
1094
+ /// # Examples
1095
+ ///
1096
+ /// ```
1097
+ /// use std::collections::BTreeMap;
1098
+ ///
1099
+ /// let mut map = BTreeMap::new();
1100
+ /// map.insert(1u, "a");
1101
+ /// map.insert(2u, "b");
1102
+ /// map.insert(3u, "c");
1103
+ ///
1104
+ /// for (key, value) in map.into_iter() {
1105
+ /// println!("{}: {}", key, value);
1106
+ /// }
1107
+ /// ```
1075
1108
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1076
1109
pub fn into_iter ( self ) -> MoveEntries < K , V > {
1077
1110
let len = self . len ( ) ;
0 commit comments