Skip to content

Commit

Permalink
Add insert on occupied entry
Browse files Browse the repository at this point in the history
  • Loading branch information
stusmall committed Oct 29, 2018
1 parent 2e4190d commit dfde781
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ impl<'a, K: Hash + Eq, V, S: BuildHasher> OccupiedEntry<'a, K, V, S> {
pub fn get_mut(&mut self) -> &mut V {
&mut self.entry.get_mut().value
}

/// Sets the value of the entry, and returns the entry's old value
pub fn insert(&mut self, value: V, duration: Duration) -> V {
let internal_entry = self.entry.insert(InternalEntry::new(value, duration));
internal_entry.value
}
}


Expand Down

0 comments on commit dfde781

Please sign in to comment.