pub struct SharedMap<K: Eq + Clone + Hash, V>(/* private fields */);Expand description
Concurrent map wrapper over DashMap providing ergonomic scoped access.
Implementations§
Sourcepub fn get_cloned(&self, key: &K) -> Option<V>where
V: Clone,
pub fn get_cloned(&self, key: &K) -> Option<V>where
V: Clone,
Get an owned clone of a value.
This releases the map entry guard immediately, so the entry may be removed
or replaced while the caller is still using the clone. Use this only when
stale clones are acceptable. Prefer Self::with or Self::with_mut
when later work depends on the entry still being present.
Sourcepub fn with<F, R>(&self, key: &K, f: F) -> Option<R>
pub fn with<F, R>(&self, key: &K, f: F) -> Option<R>
Read a value for a key using a closure.
Caution: f runs while the entry guard is held. Avoid re-entering this
SharedMap from inside the closure.
Sourcepub fn with_mut<F, R>(&self, key: &K, f: F) -> Option<R>
pub fn with_mut<F, R>(&self, key: &K, f: F) -> Option<R>
Mutate a value for a key using a closure.
Caution: f runs while the entry guard is held. Avoid re-entering this
SharedMap from inside the closure.
Sourcepub fn with_mut_or_insert_with<F, D, R>(&self, key: K, default: D, f: F) -> R
pub fn with_mut_or_insert_with<F, D, R>(&self, key: K, default: D, f: F) -> R
Mutate an entry, inserting a value produced by default when absent.
Sourcepub fn with_mut_or_default<F, R>(&self, key: K, f: F) -> R
pub fn with_mut_or_default<F, R>(&self, key: K, f: F) -> R
Mutate an entry, inserting its default value when absent.
Sourcepub fn for_each<F, Ret>(&self, f: F)
pub fn for_each<F, Ret>(&self, f: F)
Iterate over all entries immutably.
Caution: f runs while an iterator entry guard is held. Avoid
re-entering this SharedMap from inside the closure.
Sourcepub fn for_each_mut<F, Ret>(&self, f: F)
pub fn for_each_mut<F, Ret>(&self, f: F)
Iterate over all entries mutably.
Caution: f runs while an iterator entry guard is held. Avoid
re-entering this SharedMap from inside the closure.
Sourcepub fn try_for_each_mut<F, E>(&self, f: F) -> Result<(), E>
pub fn try_for_each_mut<F, E>(&self, f: F) -> Result<(), E>
Fallible mutable iteration over all entries.
Caution: f runs while an iterator entry guard is held. Avoid
re-entering this SharedMap from inside the closure.
Sourcepub fn try_for_each<F, E>(&self, f: F) -> Result<(), E>
pub fn try_for_each<F, E>(&self, f: F) -> Result<(), E>
Fallible iteration over all entries.
Caution: f runs while an iterator entry guard is held. Avoid
re-entering this SharedMap from inside the closure.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Check if a key exists.