Skip to content

Commit

Permalink
Add Entry get_mut and into_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed Apr 11, 2024
1 parent 06ec8ec commit 161159e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,22 @@ impl<'a, V> Entry<'a, V> {
}
}

#[inline]
pub fn get_mut(&mut self) -> Option<&mut V> {
match self {
Entry::Occupied(OccupiedEntry { leaf }) => Some(&mut leaf.value),
_ => None,
}
}

#[inline]
pub fn into_mut(self) -> Option<&'a mut V> {
match self {
Entry::Occupied(OccupiedEntry { leaf }) => Some(&mut leaf.value),
_ => None,
}
}

#[inline]
pub fn or_insert(self, value: V) -> &'a mut V {
self.or_insert_with(|| value)
Expand Down

0 comments on commit 161159e

Please sign in to comment.