pub struct EntryByVal<'a, K: Eq + Hash, V> { /* private fields */ }Expand description
An RAII guard providing exclusive access to a key-value pair in the LockMap.
When dropped, this type automatically unlocks the entry allowing other threads to access it.
§Type Parameters
'a- Lifetime of theLockMapK- Key type that must implementEq + HashV- Value type
§Examples
use lockmap::LockMap;
let map = LockMap::new();
{
// Get exclusive access to an entry
let mut entry = map.entry("key");
// Modify the value
entry.insert(42);
// EntryByVal is automatically unlocked when dropped
}Implementations§
Source§impl<K: Eq + Hash, V> EntryByVal<'_, K, V>
impl<K: Eq + Hash, V> EntryByVal<'_, K, V>
Sourcepub fn get(&self) -> &Option<V>
pub fn get(&self) -> &Option<V>
Returns a reference to the entry’s value.
§Returns
A reference to Some(V) if the entry has a value, or None if the entry is vacant.
Sourcepub fn get_mut(&mut self) -> &mut Option<V>
pub fn get_mut(&mut self) -> &mut Option<V>
Returns a mutable reference to the entry’s value.
§Returns
A mutable reference to Some(V) if the entry has a value, or None if the entry is vacant.
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V> Freeze for EntryByVal<'a, K, V>where
K: Freeze,
impl<'a, K, V> !RefUnwindSafe for EntryByVal<'a, K, V>
impl<'a, K, V> !Send for EntryByVal<'a, K, V>
impl<'a, K, V> !Sync for EntryByVal<'a, K, V>
impl<'a, K, V> Unpin for EntryByVal<'a, K, V>where
K: Unpin,
impl<'a, K, V> !UnwindSafe for EntryByVal<'a, K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more