pub struct SieveCache<K: Eq + Hash + Clone, V> { /* private fields */ }Expand description
A cache based on the SIEVE eviction algorithm.
Implementations§
Source§impl<K: Eq + Hash + Clone, V> SieveCache<K, V>
impl<K: Eq + Hash + Clone, V> SieveCache<K, V>
Sourcepub fn new(capacity: usize) -> Result<Self, &'static str>
pub fn new(capacity: usize) -> Result<Self, &'static str>
Create a new cache with the given capacity.
Sourcepub fn contains_key<Q>(&mut self, key: &Q) -> bool
pub fn contains_key<Q>(&mut self, key: &Q) -> bool
Return true if there is a value in the cache mapped to by key.
Sourcepub fn get<Q>(&mut self, key: &Q) -> Option<&V>
pub fn get<Q>(&mut self, key: &Q) -> Option<&V>
Get an immutable reference to the value in the cache mapped to by key.
If no value exists for key, this returns None.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Get a mutable reference to the value in the cache mapped to by key.
If no value exists for key, this returns None.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for SieveCache<K, V>
impl<K, V> RefUnwindSafe for SieveCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Sync for SieveCache<K, V>
impl<K, V> Unpin for SieveCache<K, V>where
K: Unpin,
impl<K, V> UnwindSafe for SieveCache<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