pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
        match self {
            Entry::Occupied(entry) => entry.into_mut(),
            Entry::Vacant(entry) => {
                let value = default(entry.key());
                entry.insert(value)
            }
        }
    }
/// Ensures a value is in the entry by inserting, if empty, the result of the default function.
/// This method allows for generating key-derived values for insertion by providing the default
/// function a reference to the key that was moved during the `.entry(key)` method call.
///
/// The reference to the moved key is provided so that cloning or copying the key is
/// unnecessary, unlike with `.or_insert_with(|| ... )`.
///
/// # Examples
///
/// ```
/// use scapegoat::SgMap;
///
/// let mut map = SgMap::<&str, usize, 10>::new();
///
/// map.entry("poneyland").or_insert_with_key(|key| key.chars().count());
///
/// assert_eq!(map["poneyland"], 9);
/// ```
Ensures a value is in the entry by inserting, if empty, the result of the default function.
This method allows for generating key-derived values for insertion by providing the default
function a reference to the key that was moved during the `.entry(key)` method call.

The reference to the moved key is provided so that cloning or copying the key is
unnecessary, unlike with `.or_insert_with(|| ...
Ensures a value is in the entry by inserting if empty the result of the default function . This method allows for generating key - derived values for insertion by providing the default function a reference to the key that was moved during the ` . entry ( key ) ` method call . The reference to the moved key is provided so that cloning or copying the key is unnecessary unlike with ` . or_insert_with ( || ...
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
        match self {
            Entry::Occupied(entry) => entry.into_mut(),
            Entry::Vacant(entry) => {
                let value = default(entry.key());
                entry.insert(value)
            }
        }
    }
pub fn or_insert_with_key < F : FnOnce ( & K ) -> V > ( self , default : F ) -> & ' a mut V { match self { Entry :: Occupied ( entry ) => entry . into_mut ( ) , Entry :: Vacant ( entry ) => { let value = default ( entry . key ( ) ) ; entry . insert ( value ) } } }
Ensures a value is in the entry by inserting, if empty, the result of the default function.
Ensures a value is in the entry by inserting if empty the result of the default function .
self
default
F
self
default
F
examples
```
use scapegoat::SgMap.



map.entry("poneyland").or_insert_with_key(|key| key.chars().count()).


` ` ` use scapegoat :: SgMap . map . entry ( " poneyland " ) . or_insert_with_key ( |key| key . chars () . count () ) .