pub struct VacantEntry<'h, K, V, H = RandomState>where
H: BuildHasher,{ /* private fields */ }
Expand description
VacantEntry
is a view into a vacant cache entry in a HashCache
.
Implementations§
Source§impl<'h, K, V, H> VacantEntry<'h, K, V, H>
impl<'h, K, V, H> VacantEntry<'h, K, V, H>
Sourcepub fn key(&self) -> &K
pub fn key(&self) -> &K
Gets a reference to the key.
§Examples
use scc::HashCache;
let hashcache: HashCache<u64, u32> = HashCache::default();
assert_eq!(hashcache.entry(11).key(), &11);
Sourcepub fn into_key(self) -> K
pub fn into_key(self) -> K
Takes ownership of the key.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
if let Entry::Vacant(v) = hashcache.entry(17) {
assert_eq!(v.into_key(), 17);
};
Sourcepub fn put_entry(
self,
val: V,
) -> (EvictedEntry<K, V>, OccupiedEntry<'h, K, V, H>)
pub fn put_entry( self, val: V, ) -> (EvictedEntry<K, V>, OccupiedEntry<'h, K, V, H>)
Sets the value of the entry with its key, and returns an OccupiedEntry
.
Returns a key-value pair if an entry was evicted for the new key-value pair.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
if let Entry::Vacant(o) = hashcache.entry(19) {
o.put_entry(29);
}
assert_eq!(*hashcache.get(&19).unwrap().get(), 29);
Trait Implementations§
Auto Trait Implementations§
impl<'h, K, V, H> Freeze for VacantEntry<'h, K, V, H>where
K: Freeze,
impl<'h, K, V, H> RefUnwindSafe for VacantEntry<'h, K, V, H>
impl<'h, K, V, H> Send for VacantEntry<'h, K, V, H>
impl<'h, K, V, H> Sync for VacantEntry<'h, K, V, H>
impl<'h, K, V, H> Unpin for VacantEntry<'h, K, V, H>where
K: Unpin,
impl<'h, K, V, H = RandomState> !UnwindSafe for VacantEntry<'h, K, V, H>
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