pub struct DetachableMap<K, V> { /* private fields */ }
Expand description
A Map with detachable entries. After retrieval, entries can be “detached”, removing them from the map, allowing any client to expire the key in the map. They are weak, and can be upgraded to a strong reference to the stored object.
Implementations§
Source§impl<K: Hash + Eq + Clone, V> DetachableMap<K, V>
impl<K: Hash + Eq + Clone, V> DetachableMap<K, V>
Sourcepub fn new() -> DetachableMap<K, V>
pub fn new() -> DetachableMap<K, V>
Creates an empty DetachableMap
. The map is initially empty.
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<Arc<V>>
pub fn insert(&mut self, key: K, value: V) -> Option<Arc<V>>
Inserts a new item into the map at key
Returns a reference to the old item at key
if one existed or None otherwise.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
True if the map contains a value for the specified key The key may be any borrowed form of
the key’s type, with Hash
and Eq
matching the type.
Sourcepub fn get(&self, key: &K) -> Option<DetachableWeak<K, V>>
pub fn get(&self, key: &K) -> Option<DetachableWeak<K, V>>
Returns a detachable reference to the value at the given key, if it exists.
Sourcepub fn lazy_entry(&self, key: &K) -> LazyEntry<K, V>
pub fn lazy_entry(&self, key: &K) -> LazyEntry<K, V>
Returns a lazy entry. Lazy Entries can be used later to attempt to insert into the map if
the key doesn’t exist.
They can also be resolved to a detachable reference (as returned by DetachableMap::get
) if
the key already exists.