@@ -445,6 +445,9 @@ pub enum Entry<'a, K, V> {
445445}
446446
447447impl < ' 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+ ///
448451 /// Computes in **O(1)** time (amortized average).
449452 pub fn or_insert ( self , default : V ) -> & ' a mut V {
450453 match self {
@@ -453,6 +456,9 @@ impl<'a, K, V> Entry<'a, K, V> {
453456 }
454457 }
455458
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+ ///
456462 /// Computes in **O(1)** time (amortized average).
457463 pub fn or_insert_with < F > ( self , call : F ) -> & ' a mut V
458464 where
@@ -464,6 +470,8 @@ impl<'a, K, V> Entry<'a, K, V> {
464470 }
465471 }
466472
473+ /// Gets a reference to the entry's key, either within the map if occupied,
474+ /// or else the new key that was used to find the entry.
467475 pub fn key ( & self ) -> & K {
468476 match * self {
469477 Entry :: Occupied ( ref entry) => entry. key ( ) ,
@@ -583,10 +591,12 @@ pub struct VacantEntry<'a, K, V> {
583591}
584592
585593impl < ' a , K , V > VacantEntry < ' a , K , V > {
594+ /// Gets a reference to the key that was used to find the entry.
586595 pub fn key ( & self ) -> & K {
587596 & self . key
588597 }
589598
599+ /// Takes ownership of the key, leaving the entry vacant.
590600 pub fn into_key ( self ) -> K {
591601 self . key
592602 }
@@ -596,6 +606,8 @@ impl<'a, K, V> VacantEntry<'a, K, V> {
596606 self . map . len ( )
597607 }
598608
609+ /// Inserts the entry's key and the given value into the map, and returns a mutable reference
610+ /// to the value.
599611 pub fn insert ( self , value : V ) -> & ' a mut V {
600612 let i = self . map . push ( self . hash , self . key , value) ;
601613 & mut self . map . entries [ i] . value
0 commit comments