pub struct SharedSet<K: Eq + Clone + Hash>(/* private fields */);Expand description
Concurrent set wrapper over DashSet providing ergonomic scoped access.
Implementations§
Sourcepub fn get_cloned(&self, key: &K) -> Option<K>
pub fn get_cloned(&self, key: &K) -> Option<K>
Get an owned clone of an item.
This releases the set entry guard immediately, so the entry may be removed
while the caller is still using the clone. Use this only when stale clones
are acceptable. Prefer Self::with 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 an item using a closure.
Caution: f runs while the entry guard is held. Avoid re-entering this
SharedSet from inside the closure.
Sourcepub fn insert(&self, key: K) -> bool
pub fn insert(&self, key: K) -> bool
Insert a key, returning true if the key was not already present.
Sourcepub fn remove_if<F>(&self, key: &K, f: F) -> Option<K>
pub fn remove_if<F>(&self, key: &K, f: F) -> Option<K>
Remove a key if the predicate returns true, returning it if present.
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 SharedSet 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 SharedSet from inside the closure.