@@ -1102,6 +1102,16 @@ where
1102
1102
/// documentation for more.
1103
1103
///
1104
1104
/// [`iter`]: HashMap::iter
1105
+ ///
1106
+ /// # Example
1107
+ ///
1108
+ /// ```
1109
+ /// use std::collections::HashMap;
1110
+ ///
1111
+ /// let mut map = HashMap::new();
1112
+ /// map.insert("a", 1);
1113
+ /// let iter = map.iter();
1114
+ /// ```
1105
1115
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1106
1116
pub struct Iter < ' a , K : ' a , V : ' a > {
1107
1117
base : base:: Iter < ' a , K , V > ,
@@ -1129,6 +1139,16 @@ impl<K: Debug, V: Debug> fmt::Debug for Iter<'_, K, V> {
1129
1139
/// documentation for more.
1130
1140
///
1131
1141
/// [`iter_mut`]: HashMap::iter_mut
1142
+ ///
1143
+ /// # Example
1144
+ ///
1145
+ /// ```
1146
+ /// use std::collections::HashMap;
1147
+ ///
1148
+ /// let mut map = HashMap::new();
1149
+ /// map.insert("a", 1);
1150
+ /// let iter = map.iter_mut();
1151
+ /// ```
1132
1152
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1133
1153
pub struct IterMut < ' a , K : ' a , V : ' a > {
1134
1154
base : base:: IterMut < ' a , K , V > ,
@@ -1148,6 +1168,16 @@ impl<'a, K, V> IterMut<'a, K, V> {
1148
1168
/// (provided by the `IntoIterator` trait). See its documentation for more.
1149
1169
///
1150
1170
/// [`into_iter`]: IntoIterator::into_iter
1171
+ ///
1172
+ /// # Example
1173
+ ///
1174
+ /// ```
1175
+ /// use std::collections::HashMap;
1176
+ ///
1177
+ /// let mut map = HashMap::new();
1178
+ /// map.insert("a", 1);
1179
+ /// let iter = map.into_iter();
1180
+ /// ```
1151
1181
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1152
1182
pub struct IntoIter < K , V > {
1153
1183
base : base:: IntoIter < K , V > ,
@@ -1167,6 +1197,16 @@ impl<K, V> IntoIter<K, V> {
1167
1197
/// documentation for more.
1168
1198
///
1169
1199
/// [`keys`]: HashMap::keys
1200
+ ///
1201
+ /// # Example
1202
+ ///
1203
+ /// ```
1204
+ /// use std::collections::HashMap;
1205
+ ///
1206
+ /// let mut map = HashMap::new();
1207
+ /// map.insert("a", 1);
1208
+ /// let iter_keys = map.keys();
1209
+ /// ```
1170
1210
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1171
1211
pub struct Keys < ' a , K : ' a , V : ' a > {
1172
1212
inner : Iter < ' a , K , V > ,
@@ -1194,6 +1234,16 @@ impl<K: Debug, V> fmt::Debug for Keys<'_, K, V> {
1194
1234
/// documentation for more.
1195
1235
///
1196
1236
/// [`values`]: HashMap::values
1237
+ ///
1238
+ /// # Example
1239
+ ///
1240
+ /// ```
1241
+ /// use std::collections::HashMap;
1242
+ ///
1243
+ /// let mut map = HashMap::new();
1244
+ /// map.insert("a", 1);
1245
+ /// let iter_values = map.values();
1246
+ /// ```
1197
1247
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1198
1248
pub struct Values < ' a , K : ' a , V : ' a > {
1199
1249
inner : Iter < ' a , K , V > ,
@@ -1221,6 +1271,16 @@ impl<K, V: Debug> fmt::Debug for Values<'_, K, V> {
1221
1271
/// documentation for more.
1222
1272
///
1223
1273
/// [`drain`]: HashMap::drain
1274
+ ///
1275
+ /// # Example
1276
+ ///
1277
+ /// ```
1278
+ /// use std::collections::HashMap;
1279
+ ///
1280
+ /// let mut map = HashMap::new();
1281
+ /// map.insert("a", 1);
1282
+ /// let iter = map.drain();
1283
+ /// ```
1224
1284
#[ stable( feature = "drain" , since = "1.6.0" ) ]
1225
1285
pub struct Drain < ' a , K : ' a , V : ' a > {
1226
1286
base : base:: Drain < ' a , K , V > ,
@@ -1239,6 +1299,18 @@ impl<'a, K, V> Drain<'a, K, V> {
1239
1299
/// This `struct` is created by the [`drain_filter`] method on [`HashMap`].
1240
1300
///
1241
1301
/// [`drain_filter`]: HashMap::drain_filter
1302
+ ///
1303
+ /// # Example
1304
+ ///
1305
+ /// ```
1306
+ /// #![feature(hash_drain_filter)]
1307
+ ///
1308
+ /// use std::collections::HashMap;
1309
+ ///
1310
+ /// let mut map = HashMap::new();
1311
+ /// map.insert("a", 1);
1312
+ /// let iter = map.drain_filter(|_k, v| *v % 2 == 0);
1313
+ /// ```
1242
1314
#[ unstable( feature = "hash_drain_filter" , issue = "59618" ) ]
1243
1315
pub struct DrainFilter < ' a , K , V , F >
1244
1316
where
@@ -1253,6 +1325,16 @@ where
1253
1325
/// documentation for more.
1254
1326
///
1255
1327
/// [`values_mut`]: HashMap::values_mut
1328
+ ///
1329
+ /// # Example
1330
+ ///
1331
+ /// ```
1332
+ /// use std::collections::HashMap;
1333
+ ///
1334
+ /// let mut map = HashMap::new();
1335
+ /// map.insert("a", 1);
1336
+ /// let iter_values = map.values_mut();
1337
+ /// ```
1256
1338
#[ stable( feature = "map_values_mut" , since = "1.10.0" ) ]
1257
1339
pub struct ValuesMut < ' a , K : ' a , V : ' a > {
1258
1340
inner : IterMut < ' a , K , V > ,
@@ -1264,6 +1346,18 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
1264
1346
/// See its documentation for more.
1265
1347
///
1266
1348
/// [`into_keys`]: HashMap::into_keys
1349
+ ///
1350
+ /// # Example
1351
+ ///
1352
+ /// ```
1353
+ /// #![feature(map_into_keys_values)]
1354
+ ///
1355
+ /// use std::collections::HashMap;
1356
+ ///
1357
+ /// let mut map = HashMap::new();
1358
+ /// map.insert("a", 1);
1359
+ /// let iter_keys = map.into_keys();
1360
+ /// ```
1267
1361
#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
1268
1362
pub struct IntoKeys < K , V > {
1269
1363
inner : IntoIter < K , V > ,
@@ -1275,6 +1369,18 @@ pub struct IntoKeys<K, V> {
1275
1369
/// See its documentation for more.
1276
1370
///
1277
1371
/// [`into_values`]: HashMap::into_values
1372
+ ///
1373
+ /// # Example
1374
+ ///
1375
+ /// ```
1376
+ /// #![feature(map_into_keys_values)]
1377
+ ///
1378
+ /// use std::collections::HashMap;
1379
+ ///
1380
+ /// let mut map = HashMap::new();
1381
+ /// map.insert("a", 1);
1382
+ /// let iter_keys = map.into_values();
1383
+ /// ```
1278
1384
#[ unstable( feature = "map_into_keys_values" , issue = "75294" ) ]
1279
1385
pub struct IntoValues < K , V > {
1280
1386
inner : IntoIter < K , V > ,
@@ -1285,7 +1391,6 @@ pub struct IntoValues<K, V> {
1285
1391
/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
1286
1392
///
1287
1393
/// [`HashMap::raw_entry_mut`]: HashMap::raw_entry_mut
1288
-
1289
1394
#[ unstable( feature = "hash_raw_entry" , issue = "56167" ) ]
1290
1395
pub struct RawEntryBuilderMut < ' a , K : ' a , V : ' a , S : ' a > {
1291
1396
map : & ' a mut HashMap < K , V , S > ,
0 commit comments