@@ -1131,6 +1131,24 @@ impl<K, V> BTreeMap<K, V> {
1131
1131
}
1132
1132
1133
1133
/// Gets a mutable iterator over the entries of the map.
1134
+ ///
1135
+ /// # Examples
1136
+ ///
1137
+ /// ```
1138
+ /// use std::collections::BTreeMap;
1139
+ ///
1140
+ /// let mut map = BTreeMap::new();
1141
+ /// map.insert("a", 1u);
1142
+ /// map.insert("b", 2u);
1143
+ /// map.insert("c", 3u);
1144
+ ///
1145
+ /// // add 10 to the value if the key isn't "a"
1146
+ /// for (key, value) in map.iter_mut() {
1147
+ /// if key != &"a" {
1148
+ /// *value += 10;
1149
+ /// }
1150
+ /// }
1151
+ /// ```
1134
1152
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1135
1153
pub fn iter_mut < ' a > ( & ' a mut self ) -> MutEntries < ' a , K , V > {
1136
1154
let len = self . len ( ) ;
@@ -1145,6 +1163,21 @@ impl<K, V> BTreeMap<K, V> {
1145
1163
}
1146
1164
1147
1165
/// Gets an owning iterator over the entries of the map.
1166
+ ///
1167
+ /// # Examples
1168
+ ///
1169
+ /// ```
1170
+ /// use std::collections::BTreeMap;
1171
+ ///
1172
+ /// let mut map = BTreeMap::new();
1173
+ /// map.insert(1u, "a");
1174
+ /// map.insert(2u, "b");
1175
+ /// map.insert(3u, "c");
1176
+ ///
1177
+ /// for (key, value) in map.into_iter() {
1178
+ /// println!("{}: {}", key, value);
1179
+ /// }
1180
+ /// ```
1148
1181
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1149
1182
pub fn into_iter ( self ) -> MoveEntries < K , V > {
1150
1183
let len = self . len ( ) ;
0 commit comments