@@ -181,6 +181,7 @@ impl<T, S> HashSet<T, S> {
181
181
/// println!("{}", x);
182
182
/// }
183
183
/// ```
184
+ #[ inline]
184
185
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
185
186
pub fn iter ( & self ) -> Iter < ' _ , T > {
186
187
Iter { iter : self . map . keys ( ) }
@@ -198,6 +199,7 @@ impl<T, S> HashSet<T, S> {
198
199
/// v.insert(1);
199
200
/// assert_eq!(v.len(), 1);
200
201
/// ```
202
+ #[ inline]
201
203
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
202
204
pub fn len ( & self ) -> usize {
203
205
self . map . len ( )
@@ -215,6 +217,7 @@ impl<T, S> HashSet<T, S> {
215
217
/// v.insert(1);
216
218
/// assert!(!v.is_empty());
217
219
/// ```
220
+ #[ inline]
218
221
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
219
222
pub fn is_empty ( & self ) -> bool {
220
223
self . map . is_empty ( )
@@ -255,6 +258,7 @@ impl<T, S> HashSet<T, S> {
255
258
/// v.clear();
256
259
/// assert!(v.is_empty());
257
260
/// ```
261
+ #[ inline]
258
262
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
259
263
pub fn clear ( & mut self ) {
260
264
self . map . clear ( )
@@ -332,6 +336,7 @@ impl<T, S> HashSet<T, S>
332
336
/// let set: HashSet<i32> = HashSet::with_hasher(hasher);
333
337
/// let hasher: &RandomState = set.hasher();
334
338
/// ```
339
+ #[ inline]
335
340
#[ stable( feature = "hashmap_public_hasher" , since = "1.9.0" ) ]
336
341
pub fn hasher ( & self ) -> & S {
337
342
self . map . hasher ( )
@@ -353,6 +358,7 @@ impl<T, S> HashSet<T, S>
353
358
/// set.reserve(10);
354
359
/// assert!(set.capacity() >= 10);
355
360
/// ```
361
+ #[ inline]
356
362
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
357
363
pub fn reserve ( & mut self , additional : usize ) {
358
364
self . map . reserve ( additional)
@@ -397,6 +403,7 @@ impl<T, S> HashSet<T, S>
397
403
/// set.shrink_to_fit();
398
404
/// assert!(set.capacity() >= 2);
399
405
/// ```
406
+ #[ inline]
400
407
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
401
408
pub fn shrink_to_fit ( & mut self ) {
402
409
self . map . shrink_to_fit ( )
@@ -453,6 +460,7 @@ impl<T, S> HashSet<T, S>
453
460
/// let diff: HashSet<_> = b.difference(&a).collect();
454
461
/// assert_eq!(diff, [4].iter().collect());
455
462
/// ```
463
+ #[ inline]
456
464
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
457
465
pub fn difference < ' a > ( & ' a self , other : & ' a HashSet < T , S > ) -> Difference < ' a , T , S > {
458
466
Difference {
@@ -482,6 +490,7 @@ impl<T, S> HashSet<T, S>
482
490
/// assert_eq!(diff1, diff2);
483
491
/// assert_eq!(diff1, [1, 4].iter().collect());
484
492
/// ```
493
+ #[ inline]
485
494
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
486
495
pub fn symmetric_difference < ' a > ( & ' a self ,
487
496
other : & ' a HashSet < T , S > )
@@ -507,6 +516,7 @@ impl<T, S> HashSet<T, S>
507
516
/// let intersection: HashSet<_> = a.intersection(&b).collect();
508
517
/// assert_eq!(intersection, [2, 3].iter().collect());
509
518
/// ```
519
+ #[ inline]
510
520
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
511
521
pub fn intersection < ' a > ( & ' a self , other : & ' a HashSet < T , S > ) -> Intersection < ' a , T , S > {
512
522
if self . len ( ) <= other. len ( ) {
@@ -540,6 +550,7 @@ impl<T, S> HashSet<T, S>
540
550
/// let union: HashSet<_> = a.union(&b).collect();
541
551
/// assert_eq!(union, [1, 2, 3, 4].iter().collect());
542
552
/// ```
553
+ #[ inline]
543
554
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
544
555
pub fn union < ' a > ( & ' a self , other : & ' a HashSet < T , S > ) -> Union < ' a , T , S > {
545
556
if self . len ( ) <= other. len ( ) {
@@ -571,6 +582,7 @@ impl<T, S> HashSet<T, S>
571
582
///
572
583
/// [`Eq`]: ../../std/cmp/trait.Eq.html
573
584
/// [`Hash`]: ../../std/hash/trait.Hash.html
585
+ #[ inline]
574
586
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
575
587
pub fn contains < Q : ?Sized > ( & self , value : & Q ) -> bool
576
588
where T : Borrow < Q > ,
@@ -597,6 +609,7 @@ impl<T, S> HashSet<T, S>
597
609
///
598
610
/// [`Eq`]: ../../std/cmp/trait.Eq.html
599
611
/// [`Hash`]: ../../std/hash/trait.Hash.html
612
+ #[ inline]
600
613
#[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
601
614
pub fn get < Q : ?Sized > ( & self , value : & Q ) -> Option < & T >
602
615
where T : Borrow < Q > ,
@@ -700,6 +713,7 @@ impl<T, S> HashSet<T, S>
700
713
/// assert_eq!(set.insert(2), false);
701
714
/// assert_eq!(set.len(), 1);
702
715
/// ```
716
+ #[ inline]
703
717
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
704
718
pub fn insert ( & mut self , value : T ) -> bool {
705
719
self . map . insert ( value, ( ) ) . is_none ( )
@@ -720,6 +734,7 @@ impl<T, S> HashSet<T, S>
720
734
/// set.replace(Vec::with_capacity(10));
721
735
/// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10);
722
736
/// ```
737
+ #[ inline]
723
738
#[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
724
739
pub fn replace ( & mut self , value : T ) -> Option < T > {
725
740
match self . map . entry ( value) {
@@ -752,6 +767,7 @@ impl<T, S> HashSet<T, S>
752
767
///
753
768
/// [`Eq`]: ../../std/cmp/trait.Eq.html
754
769
/// [`Hash`]: ../../std/hash/trait.Hash.html
770
+ #[ inline]
755
771
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
756
772
pub fn remove < Q : ?Sized > ( & mut self , value : & Q ) -> bool
757
773
where T : Borrow < Q > ,
@@ -778,6 +794,7 @@ impl<T, S> HashSet<T, S>
778
794
///
779
795
/// [`Eq`]: ../../std/cmp/trait.Eq.html
780
796
/// [`Hash`]: ../../std/hash/trait.Hash.html
797
+ #[ inline]
781
798
#[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
782
799
pub fn take < Q : ?Sized > ( & mut self , value : & Q ) -> Option < T >
783
800
where T : Borrow < Q > ,
@@ -844,6 +861,7 @@ impl<T, S> FromIterator<T> for HashSet<T, S>
844
861
where T : Eq + Hash ,
845
862
S : BuildHasher + Default
846
863
{
864
+ #[ inline]
847
865
fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> HashSet < T , S > {
848
866
let mut set = HashSet :: with_hasher ( Default :: default ( ) ) ;
849
867
set. extend ( iter) ;
@@ -856,6 +874,7 @@ impl<T, S> Extend<T> for HashSet<T, S>
856
874
where T : Eq + Hash ,
857
875
S : BuildHasher
858
876
{
877
+ #[ inline]
859
878
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
860
879
self . map . extend ( iter. into_iter ( ) . map ( |k| ( k, ( ) ) ) ) ;
861
880
}
@@ -866,6 +885,7 @@ impl<'a, T, S> Extend<&'a T> for HashSet<T, S>
866
885
where T : ' a + Eq + Hash + Copy ,
867
886
S : BuildHasher
868
887
{
888
+ #[ inline]
869
889
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
870
890
self . extend ( iter. into_iter ( ) . cloned ( ) ) ;
871
891
}
@@ -877,6 +897,7 @@ impl<T, S> Default for HashSet<T, S>
877
897
S : BuildHasher + Default
878
898
{
879
899
/// Creates an empty `HashSet<T, S>` with the `Default` value for the hasher.
900
+ #[ inline]
880
901
fn default ( ) -> HashSet < T , S > {
881
902
HashSet { map : HashMap :: default ( ) }
882
903
}
@@ -1105,6 +1126,7 @@ impl<'a, T, S> IntoIterator for &'a HashSet<T, S> {
1105
1126
type Item = & ' a T ;
1106
1127
type IntoIter = Iter < ' a , T > ;
1107
1128
1129
+ #[ inline]
1108
1130
fn into_iter ( self ) -> Iter < ' a , T > {
1109
1131
self . iter ( )
1110
1132
}
@@ -1135,13 +1157,15 @@ impl<T, S> IntoIterator for HashSet<T, S> {
1135
1157
/// println!("{}", x);
1136
1158
/// }
1137
1159
/// ```
1160
+ #[ inline]
1138
1161
fn into_iter ( self ) -> IntoIter < T > {
1139
1162
IntoIter { iter : self . map . into_iter ( ) }
1140
1163
}
1141
1164
}
1142
1165
1143
1166
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1144
1167
impl < K > Clone for Iter < ' _ , K > {
1168
+ #[ inline]
1145
1169
fn clone ( & self ) -> Self {
1146
1170
Iter { iter : self . iter . clone ( ) }
1147
1171
}
@@ -1150,15 +1174,18 @@ impl<K> Clone for Iter<'_, K> {
1150
1174
impl < ' a , K > Iterator for Iter < ' a , K > {
1151
1175
type Item = & ' a K ;
1152
1176
1177
+ #[ inline]
1153
1178
fn next ( & mut self ) -> Option < & ' a K > {
1154
1179
self . iter . next ( )
1155
1180
}
1181
+ #[ inline]
1156
1182
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1157
1183
self . iter . size_hint ( )
1158
1184
}
1159
1185
}
1160
1186
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1161
1187
impl < K > ExactSizeIterator for Iter < ' _ , K > {
1188
+ #[ inline]
1162
1189
fn len ( & self ) -> usize {
1163
1190
self . iter . len ( )
1164
1191
}
@@ -1177,15 +1204,18 @@ impl<K: fmt::Debug> fmt::Debug for Iter<'_, K> {
1177
1204
impl < K > Iterator for IntoIter < K > {
1178
1205
type Item = K ;
1179
1206
1207
+ #[ inline]
1180
1208
fn next ( & mut self ) -> Option < K > {
1181
1209
self . iter . next ( ) . map ( |( k, _) | k)
1182
1210
}
1211
+ #[ inline]
1183
1212
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1184
1213
self . iter . size_hint ( )
1185
1214
}
1186
1215
}
1187
1216
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1188
1217
impl < K > ExactSizeIterator for IntoIter < K > {
1218
+ #[ inline]
1189
1219
fn len ( & self ) -> usize {
1190
1220
self . iter . len ( )
1191
1221
}
@@ -1208,15 +1238,18 @@ impl<K: fmt::Debug> fmt::Debug for IntoIter<K> {
1208
1238
impl < ' a , K > Iterator for Drain < ' a , K > {
1209
1239
type Item = K ;
1210
1240
1241
+ #[ inline]
1211
1242
fn next ( & mut self ) -> Option < K > {
1212
1243
self . iter . next ( ) . map ( |( k, _) | k)
1213
1244
}
1245
+ #[ inline]
1214
1246
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1215
1247
self . iter . size_hint ( )
1216
1248
}
1217
1249
}
1218
1250
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1219
1251
impl < K > ExactSizeIterator for Drain < ' _ , K > {
1252
+ #[ inline]
1220
1253
fn len ( & self ) -> usize {
1221
1254
self . iter . len ( )
1222
1255
}
@@ -1237,6 +1270,7 @@ impl<K: fmt::Debug> fmt::Debug for Drain<'_, K> {
1237
1270
1238
1271
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1239
1272
impl < T , S > Clone for Intersection < ' _ , T , S > {
1273
+ #[ inline]
1240
1274
fn clone ( & self ) -> Self {
1241
1275
Intersection { iter : self . iter . clone ( ) , ..* self }
1242
1276
}
@@ -1249,6 +1283,7 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S>
1249
1283
{
1250
1284
type Item = & ' a T ;
1251
1285
1286
+ #[ inline]
1252
1287
fn next ( & mut self ) -> Option < & ' a T > {
1253
1288
loop {
1254
1289
let elt = self . iter . next ( ) ?;
@@ -1258,6 +1293,7 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S>
1258
1293
}
1259
1294
}
1260
1295
1296
+ #[ inline]
1261
1297
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1262
1298
let ( _, upper) = self . iter . size_hint ( ) ;
1263
1299
( 0 , upper)
@@ -1283,6 +1319,7 @@ impl<T, S> FusedIterator for Intersection<'_, T, S>
1283
1319
1284
1320
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1285
1321
impl < T , S > Clone for Difference < ' _ , T , S > {
1322
+ #[ inline]
1286
1323
fn clone ( & self ) -> Self {
1287
1324
Difference { iter : self . iter . clone ( ) , ..* self }
1288
1325
}
@@ -1295,6 +1332,7 @@ impl<'a, T, S> Iterator for Difference<'a, T, S>
1295
1332
{
1296
1333
type Item = & ' a T ;
1297
1334
1335
+ #[ inline]
1298
1336
fn next ( & mut self ) -> Option < & ' a T > {
1299
1337
loop {
1300
1338
let elt = self . iter . next ( ) ?;
@@ -1304,6 +1342,7 @@ impl<'a, T, S> Iterator for Difference<'a, T, S>
1304
1342
}
1305
1343
}
1306
1344
1345
+ #[ inline]
1307
1346
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1308
1347
let ( _, upper) = self . iter . size_hint ( ) ;
1309
1348
( 0 , upper)
@@ -1329,6 +1368,7 @@ impl<T, S> fmt::Debug for Difference<'_, T, S>
1329
1368
1330
1369
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1331
1370
impl < T , S > Clone for SymmetricDifference < ' _ , T , S > {
1371
+ #[ inline]
1332
1372
fn clone ( & self ) -> Self {
1333
1373
SymmetricDifference { iter : self . iter . clone ( ) }
1334
1374
}
@@ -1341,9 +1381,11 @@ impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S>
1341
1381
{
1342
1382
type Item = & ' a T ;
1343
1383
1384
+ #[ inline]
1344
1385
fn next ( & mut self ) -> Option < & ' a T > {
1345
1386
self . iter . next ( )
1346
1387
}
1388
+ #[ inline]
1347
1389
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1348
1390
self . iter . size_hint ( )
1349
1391
}
@@ -1368,6 +1410,7 @@ impl<T, S> fmt::Debug for SymmetricDifference<'_, T, S>
1368
1410
1369
1411
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1370
1412
impl < T , S > Clone for Union < ' _ , T , S > {
1413
+ #[ inline]
1371
1414
fn clone ( & self ) -> Self {
1372
1415
Union { iter : self . iter . clone ( ) }
1373
1416
}
@@ -1397,9 +1440,11 @@ impl<'a, T, S> Iterator for Union<'a, T, S>
1397
1440
{
1398
1441
type Item = & ' a T ;
1399
1442
1443
+ #[ inline]
1400
1444
fn next ( & mut self ) -> Option < & ' a T > {
1401
1445
self . iter . next ( )
1402
1446
}
1447
+ #[ inline]
1403
1448
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1404
1449
self . iter . size_hint ( )
1405
1450
}
0 commit comments