pub struct ConsumableEntry<'b, K, V> { /* private fields */ }Expand description
ConsumableEntry is a view into an occupied entry in a HashCache when iterating over
entries in it.
Implementations§
Source§impl<K, V> ConsumableEntry<'_, K, V>
impl<K, V> ConsumableEntry<'_, K, V>
Sourcepub fn consume(self) -> (K, V)
pub fn consume(self) -> (K, V)
Consumes the entry by moving out the key and value.
§Examples
use scc::HashCache;
let hashcache: HashCache<u64, u32> = HashCache::default();
assert!(hashcache.put_sync(1, 0).is_ok());
assert!(hashcache.put_sync(2, 1).is_ok());
assert!(hashcache.put_sync(3, 2).is_ok());
let mut consumed = None;
hashcache.iter_mut_sync(|mut e| {
if *e.key() == 1 {
*e = 2;
consumed.replace(e.consume().1);
}
true
});
assert!(!hashcache.contains_sync(&1));
assert_eq!(consumed, Some(2));Sourcepub fn key(&self) -> &K
pub fn key(&self) -> &K
Returns a reference to the entry.
§Examples
use scc::HashCache;
let hashcache: HashCache<u64, u32> = HashCache::default();
assert!(hashcache.put_sync(1, 0).is_ok());
assert!(hashcache.put_sync(2, 1).is_ok());
assert!(hashcache.put_sync(3, 2).is_ok());
hashcache.iter_mut_sync(|e| {
if *e.key() == 1 {
assert_eq!(*e, 0);
}
true
});Trait Implementations§
Source§impl<K, V> Deref for ConsumableEntry<'_, K, V>
impl<K, V> Deref for ConsumableEntry<'_, K, V>
Auto Trait Implementations§
impl<'b, K, V> Freeze for ConsumableEntry<'b, K, V>
impl<'b, K, V> !RefUnwindSafe for ConsumableEntry<'b, K, V>
impl<'b, K, V> Send for ConsumableEntry<'b, K, V>
impl<'b, K, V> Sync for ConsumableEntry<'b, K, V>
impl<'b, K, V> Unpin for ConsumableEntry<'b, K, V>
impl<'b, K, V> UnsafeUnpin for ConsumableEntry<'b, K, V>
impl<'b, K, V> !UnwindSafe for ConsumableEntry<'b, 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
Mutably borrows from an owned value. Read more