Skip to content

Commit

Permalink
Merge pull request #143 from jeromefroe/jerome/use-fnonce-instead-of-fn
Browse files Browse the repository at this point in the history
Use FnOnce instead of Fn
  • Loading branch information
jeromefroe authored Jun 14, 2022
2 parents 858882e + 9dcf6c7 commit b8970d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {

/// Returns a reference to the value of the key in the cache if it is
/// present in the cache and moves the key to the head of the LRU list.
/// If the key does not exist the provided `Fn` is used to populate the list and a reference
/// is returned.
/// If the key does not exist the provided `FnOnce` is used to populate
/// the list and a reference is returned.
///
/// This method will only return `None` when the capacity of the cache is 0 and no entries
/// can be populated.
Expand All @@ -476,7 +476,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// ```
pub fn get_or_insert<'a, F>(&'a mut self, k: K, f: F) -> Option<&'a V>
where
F: Fn() -> V,
F: FnOnce() -> V,
{
if let Some(node) = self.map.get_mut(&KeyRef { k: &k }) {
let node_ptr: *mut LruEntry<K, V> = &mut **node;
Expand Down

0 comments on commit b8970d0

Please sign in to comment.