pub struct OccupiedEntry<'h, K, V, H = RandomState>where
H: BuildHasher,{ /* private fields */ }
Expand description
OccupiedEntry
is a view into an occupied cache entry in a HashCache
.
Implementations§
Source§impl<'h, K, V, H> OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> OccupiedEntry<'h, K, V, H>
Sourcepub fn key(&self) -> &K
pub fn key(&self) -> &K
Gets a reference to the key in the entry.
§Examples
use scc::HashCache;
let hashcache: HashCache<u64, u32> = HashCache::default();
assert_eq!(hashcache.entry(29).or_default().1.key(), &29);
Sourcepub fn remove_entry(self) -> (K, V)
pub fn remove_entry(self) -> (K, V)
Sourcepub fn get(&self) -> &V
pub fn get(&self) -> &V
Gets a reference to the value in the entry.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
hashcache.entry(19).or_put(11);
if let Entry::Occupied(o) = hashcache.entry(19) {
assert_eq!(o.get(), &11);
};
Sourcepub fn get_mut(&mut self) -> &mut V
pub fn get_mut(&mut self) -> &mut V
Gets a mutable reference to the value in the entry.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
hashcache.entry(37).or_put(11);
if let Entry::Occupied(mut o) = hashcache.entry(37) {
*o.get_mut() += 18;
assert_eq!(*o.get(), 29);
}
assert_eq!(*hashcache.get(&37).unwrap().get(), 29);
Sourcepub fn put(&mut self, val: V) -> V
pub fn put(&mut self, val: V) -> V
Sets the value of the entry, and returns the old value.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
hashcache.entry(37).or_put(11);
if let Entry::Occupied(mut o) = hashcache.entry(37) {
assert_eq!(o.put(17), 11);
}
assert_eq!(*hashcache.get(&37).unwrap().get(), 17);
Sourcepub fn remove(self) -> V
pub fn remove(self) -> V
Takes the value out of the entry, and returns it.
§Examples
use scc::HashCache;
use scc::hash_cache::Entry;
let hashcache: HashCache<u64, u32> = HashCache::default();
hashcache.entry(11).or_put(17);
if let Entry::Occupied(o) = hashcache.entry(11) {
assert_eq!(o.remove(), 17);
};
Trait Implementations§
Source§impl<'h, K, V, H> Debug for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> Debug for OccupiedEntry<'h, K, V, H>
Source§impl<'h, K, V, H> Deref for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> Deref for OccupiedEntry<'h, K, V, H>
Auto Trait Implementations§
impl<'h, K, V, H> Freeze for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> RefUnwindSafe for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> Send for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> Sync for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H> Unpin for OccupiedEntry<'h, K, V, H>
impl<'h, K, V, H = RandomState> !UnwindSafe for OccupiedEntry<'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