Skip to content

Commit

Permalink
replace &K with K for entry.rs's or_insert_with
Browse files Browse the repository at this point in the history
  • Loading branch information
EriKWDev committed Jan 21, 2025
1 parent cd51a30 commit 0143069
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,14 @@ impl<'a, K: IntKey, V> Entry<'a, K, V> {
}

/// Ensures a value is in the entry by inserting, if empty, the result of the provided function.
///
/// Unlike its usefulness in standard hashmaps, since intmap keys are Copy this function is of little
/// particular use to intmaps but provided anyway to match the standard entry API
pub fn or_insert_with_key<F>(self, default: F) -> &'a mut V
where
F: FnOnce(&K) -> V,
F: FnOnce(K) -> V,
{
match self {
Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => {
let d = default(&entry.key);
let d = default(entry.key);
entry.insert(d)
}
}
Expand Down

0 comments on commit 0143069

Please sign in to comment.