@@ -233,7 +233,7 @@ impl<T, S> HashSet<T, S> {
233
233
/// ```
234
234
/// use std::collections::HashSet;
235
235
///
236
- /// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
236
+ /// let mut set = HashSet::from( [1, 2, 3]);
237
237
/// assert!(!set.is_empty());
238
238
///
239
239
/// // print 1, 2, 3 in an arbitrary order
@@ -489,8 +489,8 @@ where
489
489
///
490
490
/// ```
491
491
/// use std::collections::HashSet;
492
- /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
493
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
492
+ /// let a = HashSet::from( [1, 2, 3]);
493
+ /// let b = HashSet::from( [4, 2, 3, 4]);
494
494
///
495
495
/// // Can be seen as `a - b`.
496
496
/// for x in a.difference(&b) {
@@ -518,8 +518,8 @@ where
518
518
///
519
519
/// ```
520
520
/// use std::collections::HashSet;
521
- /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
522
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
521
+ /// let a = HashSet::from( [1, 2, 3]);
522
+ /// let b = HashSet::from( [4, 2, 3, 4]);
523
523
///
524
524
/// // Print 1, 4 in arbitrary order.
525
525
/// for x in a.symmetric_difference(&b) {
@@ -548,8 +548,8 @@ where
548
548
///
549
549
/// ```
550
550
/// use std::collections::HashSet;
551
- /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
552
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
551
+ /// let a = HashSet::from( [1, 2, 3]);
552
+ /// let b = HashSet::from( [4, 2, 3, 4]);
553
553
///
554
554
/// // Print 2, 3 in arbitrary order.
555
555
/// for x in a.intersection(&b) {
@@ -576,8 +576,8 @@ where
576
576
///
577
577
/// ```
578
578
/// use std::collections::HashSet;
579
- /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
580
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
579
+ /// let a = HashSet::from( [1, 2, 3]);
580
+ /// let b = HashSet::from( [4, 2, 3, 4]);
581
581
///
582
582
/// // Print 1, 2, 3, 4 in arbitrary order.
583
583
/// for x in a.union(&b) {
@@ -608,7 +608,7 @@ where
608
608
/// ```
609
609
/// use std::collections::HashSet;
610
610
///
611
- /// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
611
+ /// let set = HashSet::from( [1, 2, 3]);
612
612
/// assert_eq!(set.contains(&1), true);
613
613
/// assert_eq!(set.contains(&4), false);
614
614
/// ```
@@ -633,7 +633,7 @@ where
633
633
/// ```
634
634
/// use std::collections::HashSet;
635
635
///
636
- /// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
636
+ /// let set = HashSet::from( [1, 2, 3]);
637
637
/// assert_eq!(set.get(&2), Some(&2));
638
638
/// assert_eq!(set.get(&4), None);
639
639
/// ```
@@ -657,7 +657,7 @@ where
657
657
///
658
658
/// use std::collections::HashSet;
659
659
///
660
- /// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
660
+ /// let mut set = HashSet::from( [1, 2, 3]);
661
661
/// assert_eq!(set.len(), 3);
662
662
/// assert_eq!(set.get_or_insert(2), &2);
663
663
/// assert_eq!(set.get_or_insert(100), &100);
@@ -744,7 +744,7 @@ where
744
744
/// ```
745
745
/// use std::collections::HashSet;
746
746
///
747
- /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
747
+ /// let a = HashSet::from( [1, 2, 3]);
748
748
/// let mut b = HashSet::new();
749
749
///
750
750
/// assert_eq!(a.is_disjoint(&b), true);
@@ -770,7 +770,7 @@ where
770
770
/// ```
771
771
/// use std::collections::HashSet;
772
772
///
773
- /// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
773
+ /// let sup = HashSet::from( [1, 2, 3]);
774
774
/// let mut set = HashSet::new();
775
775
///
776
776
/// assert_eq!(set.is_subset(&sup), true);
@@ -792,7 +792,7 @@ where
792
792
/// ```
793
793
/// use std::collections::HashSet;
794
794
///
795
- /// let sub: HashSet<_> = [1, 2].iter().cloned().collect( );
795
+ /// let sub = HashSet::from( [1, 2]);
796
796
/// let mut set = HashSet::new();
797
797
///
798
798
/// assert_eq!(set.is_superset(&sub), false);
@@ -893,7 +893,7 @@ where
893
893
/// ```
894
894
/// use std::collections::HashSet;
895
895
///
896
- /// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect( );
896
+ /// let mut set = HashSet::from( [1, 2, 3]);
897
897
/// assert_eq!(set.take(&2), Some(2));
898
898
/// assert_eq!(set.take(&2), None);
899
899
/// ```
@@ -917,8 +917,7 @@ where
917
917
/// ```
918
918
/// use std::collections::HashSet;
919
919
///
920
- /// let xs = [1, 2, 3, 4, 5, 6];
921
- /// let mut set: HashSet<i32> = xs.iter().cloned().collect();
920
+ /// let mut set = HashSet::from([1, 2, 3, 4, 5, 6]);
922
921
/// set.retain(|&k| k % 2 == 0);
923
922
/// assert_eq!(set.len(), 3);
924
923
/// ```
@@ -1097,8 +1096,8 @@ where
1097
1096
/// ```
1098
1097
/// use std::collections::HashSet;
1099
1098
///
1100
- /// let a: HashSet<_> = vec! [1, 2, 3].into_iter().collect( );
1101
- /// let b: HashSet<_> = vec! [3, 4, 5].into_iter().collect( );
1099
+ /// let a = HashSet::from( [1, 2, 3]);
1100
+ /// let b = HashSet::from( [3, 4, 5]);
1102
1101
///
1103
1102
/// let set = &a | &b;
1104
1103
///
@@ -1130,8 +1129,8 @@ where
1130
1129
/// ```
1131
1130
/// use std::collections::HashSet;
1132
1131
///
1133
- /// let a: HashSet<_> = vec! [1, 2, 3].into_iter().collect( );
1134
- /// let b: HashSet<_> = vec! [2, 3, 4].into_iter().collect( );
1132
+ /// let a = HashSet::from( [1, 2, 3]);
1133
+ /// let b = HashSet::from( [2, 3, 4]);
1135
1134
///
1136
1135
/// let set = &a & &b;
1137
1136
///
@@ -1163,8 +1162,8 @@ where
1163
1162
/// ```
1164
1163
/// use std::collections::HashSet;
1165
1164
///
1166
- /// let a: HashSet<_> = vec! [1, 2, 3].into_iter().collect( );
1167
- /// let b: HashSet<_> = vec! [3, 4, 5].into_iter().collect( );
1165
+ /// let a = HashSet::from( [1, 2, 3]);
1166
+ /// let b = HashSet::from( [3, 4, 5]);
1168
1167
///
1169
1168
/// let set = &a ^ &b;
1170
1169
///
@@ -1196,8 +1195,8 @@ where
1196
1195
/// ```
1197
1196
/// use std::collections::HashSet;
1198
1197
///
1199
- /// let a: HashSet<_> = vec! [1, 2, 3].into_iter().collect( );
1200
- /// let b: HashSet<_> = vec! [3, 4, 5].into_iter().collect( );
1198
+ /// let a = HashSet::from( [1, 2, 3]);
1199
+ /// let b = HashSet::from( [3, 4, 5]);
1201
1200
///
1202
1201
/// let set = &a - &b;
1203
1202
///
@@ -1226,7 +1225,7 @@ where
1226
1225
/// ```
1227
1226
/// use std::collections::HashSet;
1228
1227
///
1229
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1228
+ /// let a = HashSet::from( [1, 2, 3]);
1230
1229
///
1231
1230
/// let mut iter = a.iter();
1232
1231
/// ```
@@ -1248,7 +1247,7 @@ pub struct Iter<'a, K: 'a> {
1248
1247
/// ```
1249
1248
/// use std::collections::HashSet;
1250
1249
///
1251
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1250
+ /// let a = HashSet::from( [1, 2, 3]);
1252
1251
///
1253
1252
/// let mut iter = a.into_iter();
1254
1253
/// ```
@@ -1269,7 +1268,7 @@ pub struct IntoIter<K> {
1269
1268
/// ```
1270
1269
/// use std::collections::HashSet;
1271
1270
///
1272
- /// let mut a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1271
+ /// let mut a = HashSet::from( [1, 2, 3]);
1273
1272
///
1274
1273
/// let mut drain = a.drain();
1275
1274
/// ```
@@ -1291,7 +1290,7 @@ pub struct Drain<'a, K: 'a> {
1291
1290
///
1292
1291
/// use std::collections::HashSet;
1293
1292
///
1294
- /// let mut a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1293
+ /// let mut a = HashSet::from( [1, 2, 3]);
1295
1294
///
1296
1295
/// let mut drain_filtered = a.drain_filter(|v| v % 2 == 0);
1297
1296
/// ```
@@ -1315,8 +1314,8 @@ where
1315
1314
/// ```
1316
1315
/// use std::collections::HashSet;
1317
1316
///
1318
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1319
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
1317
+ /// let a = HashSet::from( [1, 2, 3]);
1318
+ /// let b = HashSet::from( [4, 2, 3, 4]);
1320
1319
///
1321
1320
/// let mut intersection = a.intersection(&b);
1322
1321
/// ```
@@ -1342,8 +1341,8 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
1342
1341
/// ```
1343
1342
/// use std::collections::HashSet;
1344
1343
///
1345
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1346
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
1344
+ /// let a = HashSet::from( [1, 2, 3]);
1345
+ /// let b = HashSet::from( [4, 2, 3, 4]);
1347
1346
///
1348
1347
/// let mut difference = a.difference(&b);
1349
1348
/// ```
@@ -1369,8 +1368,8 @@ pub struct Difference<'a, T: 'a, S: 'a> {
1369
1368
/// ```
1370
1369
/// use std::collections::HashSet;
1371
1370
///
1372
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1373
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
1371
+ /// let a = HashSet::from( [1, 2, 3]);
1372
+ /// let b = HashSet::from( [4, 2, 3, 4]);
1374
1373
///
1375
1374
/// let mut intersection = a.symmetric_difference(&b);
1376
1375
/// ```
@@ -1393,8 +1392,8 @@ pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
1393
1392
/// ```
1394
1393
/// use std::collections::HashSet;
1395
1394
///
1396
- /// let a: HashSet<u32> = vec! [1, 2, 3].into_iter().collect( );
1397
- /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect( );
1395
+ /// let a = HashSet::from( [1, 2, 3]);
1396
+ /// let b = HashSet::from( [4, 2, 3, 4]);
1398
1397
///
1399
1398
/// let mut union_iter = a.union(&b);
1400
1399
/// ```
0 commit comments