@@ -445,6 +445,9 @@ pub enum Entry<'a, K, V> {
445
445
}
446
446
447
447
impl < ' a , K , V > Entry < ' a , K , V > {
448
+ /// Inserts the given default value in the entry if it is vacant and returns a mutable
449
+ /// reference to it. Otherwise a mutable reference to an already existent value is returned.
450
+ ///
448
451
/// Computes in **O(1)** time (amortized average).
449
452
pub fn or_insert ( self , default : V ) -> & ' a mut V {
450
453
match self {
@@ -453,6 +456,9 @@ impl<'a, K, V> Entry<'a, K, V> {
453
456
}
454
457
}
455
458
459
+ /// Inserts the result of the `call` function in the entry if it is vacant and returns a mutable
460
+ /// reference to it. Otherwise a mutable reference to an already existent value is returned.
461
+ ///
456
462
/// Computes in **O(1)** time (amortized average).
457
463
pub fn or_insert_with < F > ( self , call : F ) -> & ' a mut V
458
464
where
@@ -590,6 +596,7 @@ impl<'a, K, V> VacantEntry<'a, K, V> {
590
596
& self . key
591
597
}
592
598
599
+ /// Takes ownership of the key, leaving the entry vacant.
593
600
pub fn into_key ( self ) -> K {
594
601
self . key
595
602
}
@@ -599,6 +606,8 @@ impl<'a, K, V> VacantEntry<'a, K, V> {
599
606
self . map . len ( )
600
607
}
601
608
609
+ /// Inserts the entry's key and the given value into the map, and returns a mutable reference
610
+ /// to the value.
602
611
pub fn insert ( self , value : V ) -> & ' a mut V {
603
612
let i = self . map . push ( self . hash , self . key , value) ;
604
613
& mut self . map . entries [ i] . value
0 commit comments