@@ -973,6 +973,7 @@ where
973
973
/// so that the map now contains keys which compare equal, search may start
974
974
/// acting erratically, with two keys randomly masking each other. Implementations
975
975
/// are free to assume this doesn't happen (within the limits of memory-safety).
976
+ #[ inline]
976
977
pub fn raw_entry_mut ( & mut self ) -> RawEntryBuilderMut < K , V , S > {
977
978
self . reserve ( 1 ) ;
978
979
RawEntryBuilderMut { map : self }
@@ -993,6 +994,7 @@ where
993
994
/// `get` should be preferred.
994
995
///
995
996
/// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`.
997
+ #[ inline]
996
998
pub fn raw_entry ( & self ) -> RawEntryBuilder < K , V , S > {
997
999
RawEntryBuilder { map : self }
998
1000
}
@@ -1283,6 +1285,7 @@ where
1283
1285
K : Eq + Hash ,
1284
1286
{
1285
1287
/// Create a `RawEntryMut` from the given key.
1288
+ #[ inline]
1286
1289
pub fn from_key < Q : ?Sized > ( self , k : & Q ) -> RawEntryMut < ' a , K , V , S >
1287
1290
where
1288
1291
K : Borrow < Q > ,
@@ -1294,6 +1297,7 @@ where
1294
1297
}
1295
1298
1296
1299
/// Create a `RawEntryMut` from the given key and its hash.
1300
+ #[ inline]
1297
1301
pub fn from_key_hashed_nocheck < Q : ?Sized > ( self , hash : u64 , k : & Q ) -> RawEntryMut < ' a , K , V , S >
1298
1302
where
1299
1303
K : Borrow < Q > ,
@@ -1302,6 +1306,7 @@ where
1302
1306
self . from_hash ( hash, |q| q. borrow ( ) . eq ( k) )
1303
1307
}
1304
1308
1309
+ #[ inline]
1305
1310
fn search < F > ( self , hash : u64 , mut is_match : F ) -> RawEntryMut < ' a , K , V , S >
1306
1311
where
1307
1312
for < ' b > F : FnMut ( & ' b K ) -> bool ,
@@ -1319,6 +1324,7 @@ where
1319
1324
}
1320
1325
1321
1326
/// Create a `RawEntryMut` from the given hash.
1327
+ #[ inline]
1322
1328
pub fn from_hash < F > ( self , hash : u64 , is_match : F ) -> RawEntryMut < ' a , K , V , S >
1323
1329
where
1324
1330
for < ' b > F : FnMut ( & ' b K ) -> bool ,
@@ -1329,6 +1335,7 @@ where
1329
1335
/// Search possible locations for an element with hash `hash` until `is_match` returns true for
1330
1336
/// one of them. There is no guarantee that all keys passed to `is_match` will have the provided
1331
1337
/// hash.
1338
+ #[ inline]
1332
1339
pub fn search_bucket < F > ( self , hash : u64 , is_match : F ) -> RawEntryMut < ' a , K , V , S >
1333
1340
where
1334
1341
for < ' b > F : FnMut ( & ' b K ) -> bool ,
@@ -1342,6 +1349,7 @@ where
1342
1349
S : BuildHasher ,
1343
1350
{
1344
1351
/// Access an entry by key.
1352
+ #[ inline]
1345
1353
pub fn from_key < Q : ?Sized > ( self , k : & Q ) -> Option < ( & ' a K , & ' a V ) >
1346
1354
where
1347
1355
K : Borrow < Q > ,
@@ -1353,6 +1361,7 @@ where
1353
1361
}
1354
1362
1355
1363
/// Access an entry by a key and its hash.
1364
+ #[ inline]
1356
1365
pub fn from_key_hashed_nocheck < Q : ?Sized > ( self , hash : u64 , k : & Q ) -> Option < ( & ' a K , & ' a V ) >
1357
1366
where
1358
1367
K : Borrow < Q > ,
@@ -1361,6 +1370,7 @@ where
1361
1370
self . from_hash ( hash, |q| q. borrow ( ) . eq ( k) )
1362
1371
}
1363
1372
1373
+ #[ inline]
1364
1374
fn search < F > ( self , hash : u64 , mut is_match : F ) -> Option < ( & ' a K , & ' a V ) >
1365
1375
where
1366
1376
F : FnMut ( & K ) -> bool ,
@@ -1375,6 +1385,7 @@ where
1375
1385
}
1376
1386
1377
1387
/// Access an entry by hash.
1388
+ #[ inline]
1378
1389
pub fn from_hash < F > ( self , hash : u64 , is_match : F ) -> Option < ( & ' a K , & ' a V ) >
1379
1390
where
1380
1391
F : FnMut ( & K ) -> bool ,
@@ -1385,6 +1396,7 @@ where
1385
1396
/// Search possible locations for an element with hash `hash` until `is_match` returns true for
1386
1397
/// one of them. There is no guarantee that all keys passed to `is_match` will have the provided
1387
1398
/// hash.
1399
+ #[ inline]
1388
1400
pub fn search_bucket < F > ( self , hash : u64 , is_match : F ) -> Option < ( & ' a K , & ' a V ) >
1389
1401
where
1390
1402
F : FnMut ( & K ) -> bool ,
@@ -1410,6 +1422,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
1410
1422
/// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2;
1411
1423
/// assert_eq!(map["poneyland"], 6);
1412
1424
/// ```
1425
+ #[ inline]
1413
1426
pub fn or_insert ( self , default_key : K , default_val : V ) -> ( & ' a mut K , & ' a mut V )
1414
1427
where
1415
1428
K : Hash ,
@@ -1437,6 +1450,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
1437
1450
///
1438
1451
/// assert_eq!(map["poneyland"], "hoho".to_string());
1439
1452
/// ```
1453
+ #[ inline]
1440
1454
pub fn or_insert_with < F > ( self , default : F ) -> ( & ' a mut K , & ' a mut V )
1441
1455
where
1442
1456
F : FnOnce ( ) -> ( K , V ) ,
@@ -1474,6 +1488,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
1474
1488
/// .or_insert("poneyland", 0);
1475
1489
/// assert_eq!(map["poneyland"], 43);
1476
1490
/// ```
1491
+ #[ inline]
1477
1492
pub fn and_modify < F > ( self , f : F ) -> Self
1478
1493
where
1479
1494
F : FnOnce ( & mut K , & mut V ) ,
@@ -1493,38 +1508,45 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
1493
1508
1494
1509
impl < ' a , K , V > RawOccupiedEntryMut < ' a , K , V > {
1495
1510
/// Gets a reference to the key in the entry.
1511
+ #[ inline]
1496
1512
pub fn key ( & self ) -> & K {
1497
1513
unsafe { & self . elem . as_ref ( ) . 0 }
1498
1514
}
1499
1515
1500
1516
/// Gets a mutable reference to the key in the entry.
1517
+ #[ inline]
1501
1518
pub fn key_mut ( & mut self ) -> & mut K {
1502
1519
unsafe { & mut self . elem . as_mut ( ) . 0 }
1503
1520
}
1504
1521
1505
1522
/// Converts the entry into a mutable reference to the key in the entry
1506
1523
/// with a lifetime bound to the map itself.
1524
+ #[ inline]
1507
1525
pub fn into_key ( self ) -> & ' a mut K {
1508
1526
unsafe { & mut self . elem . as_mut ( ) . 0 }
1509
1527
}
1510
1528
1511
1529
/// Gets a reference to the value in the entry.
1530
+ #[ inline]
1512
1531
pub fn get ( & self ) -> & V {
1513
1532
unsafe { & self . elem . as_ref ( ) . 1 }
1514
1533
}
1515
1534
1516
1535
/// Converts the OccupiedEntry into a mutable reference to the value in the entry
1517
1536
/// with a lifetime bound to the map itself.
1537
+ #[ inline]
1518
1538
pub fn into_mut ( self ) -> & ' a mut V {
1519
1539
unsafe { & mut self . elem . as_mut ( ) . 1 }
1520
1540
}
1521
1541
1522
1542
/// Gets a mutable reference to the value in the entry.
1543
+ #[ inline]
1523
1544
pub fn get_mut ( & mut self ) -> & mut V {
1524
1545
unsafe { & mut self . elem . as_mut ( ) . 1 }
1525
1546
}
1526
1547
1527
1548
/// Gets a reference to the key and value in the entry.
1549
+ #[ inline]
1528
1550
pub fn get_key_value ( & mut self ) -> ( & K , & V ) {
1529
1551
unsafe {
1530
1552
let & ( ref key, ref value) = self . elem . as_ref ( ) ;
@@ -1533,6 +1555,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
1533
1555
}
1534
1556
1535
1557
/// Gets a mutable reference to the key and value in the entry.
1558
+ #[ inline]
1536
1559
pub fn get_key_value_mut ( & mut self ) -> ( & mut K , & mut V ) {
1537
1560
unsafe {
1538
1561
let & mut ( ref mut key, ref mut value) = self . elem . as_mut ( ) ;
@@ -1542,6 +1565,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
1542
1565
1543
1566
/// Converts the OccupiedEntry into a mutable reference to the key and value in the entry
1544
1567
/// with a lifetime bound to the map itself.
1568
+ #[ inline]
1545
1569
pub fn into_key_value ( self ) -> ( & ' a mut K , & ' a mut V ) {
1546
1570
unsafe {
1547
1571
let & mut ( ref mut key, ref mut value) = self . elem . as_mut ( ) ;
@@ -1550,21 +1574,25 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
1550
1574
}
1551
1575
1552
1576
/// Sets the value of the entry, and returns the entry's old value.
1577
+ #[ inline]
1553
1578
pub fn insert ( & mut self , value : V ) -> V {
1554
1579
mem:: replace ( self . get_mut ( ) , value)
1555
1580
}
1556
1581
1557
1582
/// Sets the value of the entry, and returns the entry's old value.
1583
+ #[ inline]
1558
1584
pub fn insert_key ( & mut self , key : K ) -> K {
1559
1585
mem:: replace ( self . key_mut ( ) , key)
1560
1586
}
1561
1587
1562
1588
/// Takes the value out of the entry, and returns it.
1589
+ #[ inline]
1563
1590
pub fn remove ( self ) -> V {
1564
1591
self . remove_entry ( ) . 1
1565
1592
}
1566
1593
1567
1594
/// Take the ownership of the key and value from the map.
1595
+ #[ inline]
1568
1596
pub fn remove_entry ( self ) -> ( K , V ) {
1569
1597
unsafe {
1570
1598
self . table . erase_no_drop ( & self . elem ) ;
@@ -1576,6 +1604,7 @@ impl<'a, K, V> RawOccupiedEntryMut<'a, K, V> {
1576
1604
impl < ' a , K , V , S > RawVacantEntryMut < ' a , K , V , S > {
1577
1605
/// Sets the value of the entry with the VacantEntry's key,
1578
1606
/// and returns a mutable reference to it.
1607
+ #[ inline]
1579
1608
pub fn insert ( self , key : K , value : V ) -> ( & ' a mut K , & ' a mut V )
1580
1609
where
1581
1610
K : Hash ,
@@ -1588,6 +1617,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
1588
1617
1589
1618
/// Sets the value of the entry with the VacantEntry's key,
1590
1619
/// and returns a mutable reference to it.
1620
+ #[ inline]
1591
1621
pub fn insert_hashed_nocheck ( self , hash : u64 , key : K , value : V ) -> ( & ' a mut K , & ' a mut V )
1592
1622
where
1593
1623
K : Hash ,
0 commit comments