Struct weight_cache::WeightCache [−][src]
Implementations
impl<K: Hash + Eq, V: Weigheable> WeightCache<K, V>[src]
pub fn new(capacity: NonZeroUsize) -> Self[src]
impl<K: Hash + Eq, V: Weigheable, S: BuildHasher> WeightCache<K, V, S>[src]
pub fn with_hasher(capacity: NonZeroUsize, hasher: S) -> Self[src]
Create a WeightCache with a custom hasher.
pub fn get(&mut self, k: &K) -> Option<&V>[src]
Returns a reference to the value corresponding to the given key, if it exists.
pub fn get_mut(&mut self, k: &K) -> Option<&mut V>[src]
Returns a mutable reference to the value corresponding to the given key, if it exists.
pub fn len(&self) -> usize[src]
Returns the number of key-value pairs in the cache.
pub fn is_empty(&self) -> bool[src]
Returns true if the cache contains no key-value pairs.
pub fn put(&mut self, key: K, value: V) -> Result<(), ValueTooBigError>[src]
Inserts a key-value pair into the cache. Returns an error if the value is too bigger than the cache’s configured max size.
pub fn iter(&self) -> Iter<'_, K, V>ⓘ[src]
Returns an iterator over the cache’s key-value pairs in least- to most-recently-used order.
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘ[src]
Returns a mutable iterator over the cache’s key-value pairs in least- to most-recently-used order.
Trait Implementations
impl<K, V, S> Debug for WeightCache<K, V, S>[src]
impl<K: Hash + Eq, V: Weigheable> Default for WeightCache<K, V>[src]
impl<K: Hash + Eq, V, S: BuildHasher + Default> IntoIterator for WeightCache<K, V, S>[src]
Auto Trait Implementations
impl<K, V, S> RefUnwindSafe for WeightCache<K, V, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, S> Send for WeightCache<K, V, S> where
K: Send,
S: Send,
V: Send,
K: Send,
S: Send,
V: Send,
impl<K, V, S> Sync for WeightCache<K, V, S> where
K: Sync,
S: Sync,
V: Sync,
K: Sync,
S: Sync,
V: Sync,
impl<K, V, S> Unpin for WeightCache<K, V, S> where
S: Unpin,
S: Unpin,
impl<K, V, S> UnwindSafe for WeightCache<K, V, S> where
K: RefUnwindSafe,
S: UnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
S: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,