@@ -1173,6 +1173,16 @@ where
1173
1173
/// See its documentation for more.
1174
1174
///
1175
1175
/// [`iter`]: HashSet::iter
1176
+ ///
1177
+ /// # Examples
1178
+ ///
1179
+ /// ```
1180
+ /// use std::collections::HashSet;
1181
+ ///
1182
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1183
+ ///
1184
+ /// let mut iter = a.iter();
1185
+ /// ```
1176
1186
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1177
1187
pub struct Iter < ' a , K : ' a > {
1178
1188
base : base:: Iter < ' a , K > ,
@@ -1184,6 +1194,16 @@ pub struct Iter<'a, K: 'a> {
1184
1194
/// (provided by the `IntoIterator` trait). See its documentation for more.
1185
1195
///
1186
1196
/// [`into_iter`]: IntoIterator::into_iter
1197
+ ///
1198
+ /// # Examples
1199
+ ///
1200
+ /// ```
1201
+ /// use std::collections::HashSet;
1202
+ ///
1203
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1204
+ ///
1205
+ /// let mut iter = a.into_iter();
1206
+ /// ```
1187
1207
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1188
1208
pub struct IntoIter < K > {
1189
1209
base : base:: IntoIter < K > ,
@@ -1195,6 +1215,16 @@ pub struct IntoIter<K> {
1195
1215
/// See its documentation for more.
1196
1216
///
1197
1217
/// [`drain`]: HashSet::drain
1218
+ ///
1219
+ /// # Examples
1220
+ ///
1221
+ /// ```
1222
+ /// use std::collections::HashSet;
1223
+ ///
1224
+ /// let mut a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1225
+ ///
1226
+ /// let mut drain = a.drain();
1227
+ /// ```
1198
1228
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1199
1229
pub struct Drain < ' a , K : ' a > {
1200
1230
base : base:: Drain < ' a , K > ,
@@ -1205,6 +1235,18 @@ pub struct Drain<'a, K: 'a> {
1205
1235
/// This `struct` is created by the [`drain_filter`] method on [`HashSet`].
1206
1236
///
1207
1237
/// [`drain_filter`]: HashSet::drain_filter
1238
+ ///
1239
+ /// # Examples
1240
+ ///
1241
+ /// ```
1242
+ /// #![feature(hash_drain_filter)]
1243
+ ///
1244
+ /// use std::collections::HashSet;
1245
+ ///
1246
+ /// let mut a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1247
+ ///
1248
+ /// let mut drain_filtered = a.drain_filter(|v| v % 2 == 0);
1249
+ /// ```
1208
1250
#[ unstable( feature = "hash_drain_filter" , issue = "59618" ) ]
1209
1251
pub struct DrainFilter < ' a , K , F >
1210
1252
where
@@ -1219,6 +1261,17 @@ where
1219
1261
/// See its documentation for more.
1220
1262
///
1221
1263
/// [`intersection`]: HashSet::intersection
1264
+ ///
1265
+ /// # Examples
1266
+ ///
1267
+ /// ```
1268
+ /// use std::collections::HashSet;
1269
+ ///
1270
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1271
+ /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1272
+ ///
1273
+ /// let mut intersection = a.intersection(&b);
1274
+ /// ```
1222
1275
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1223
1276
pub struct Intersection < ' a , T : ' a , S : ' a > {
1224
1277
// iterator of the first set
@@ -1233,6 +1286,17 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
1233
1286
/// See its documentation for more.
1234
1287
///
1235
1288
/// [`difference`]: HashSet::difference
1289
+ ///
1290
+ /// # Examples
1291
+ ///
1292
+ /// ```
1293
+ /// use std::collections::HashSet;
1294
+ ///
1295
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1296
+ /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1297
+ ///
1298
+ /// let mut difference = a.difference(&b);
1299
+ /// ```
1236
1300
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1237
1301
pub struct Difference < ' a , T : ' a , S : ' a > {
1238
1302
// iterator of the first set
@@ -1247,6 +1311,17 @@ pub struct Difference<'a, T: 'a, S: 'a> {
1247
1311
/// [`HashSet`]. See its documentation for more.
1248
1312
///
1249
1313
/// [`symmetric_difference`]: HashSet::symmetric_difference
1314
+ ///
1315
+ /// # Examples
1316
+ ///
1317
+ /// ```
1318
+ /// use std::collections::HashSet;
1319
+ ///
1320
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1321
+ /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1322
+ ///
1323
+ /// let mut intersection = a.symmetric_difference(&b);
1324
+ /// ```
1250
1325
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1251
1326
pub struct SymmetricDifference < ' a , T : ' a , S : ' a > {
1252
1327
iter : Chain < Difference < ' a , T , S > , Difference < ' a , T , S > > ,
@@ -1258,6 +1333,17 @@ pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
1258
1333
/// See its documentation for more.
1259
1334
///
1260
1335
/// [`union`]: HashSet::union
1336
+ ///
1337
+ /// # Examples
1338
+ ///
1339
+ /// ```
1340
+ /// use std::collections::HashSet;
1341
+ ///
1342
+ /// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1343
+ /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1344
+ ///
1345
+ /// let mut union_iter = a.union(&b);
1346
+ /// ```
1261
1347
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1262
1348
pub struct Union < ' a , T : ' a , S : ' a > {
1263
1349
iter : Chain < Iter < ' a , T > , Difference < ' a , T , S > > ,
0 commit comments