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.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for DetachableMap<K, V>
impl<K, V> !RefUnwindSafe for DetachableMap<K, V>
impl<K, V> Send for DetachableMap<K, V>
impl<K, V> Sync for DetachableMap<K, V>
impl<K, V> Unpin for DetachableMap<K, V>
impl<K, V> !UnwindSafe for DetachableMap<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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more