clru 0.6.3

An LRU cache implementation with constant time operations and weighted semantic
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// Trait used to retrieve the weight of a key-value pair.
pub trait WeightScale<K, V> {
    /// Returns the weight of a key-value pair.
    fn weight(&self, key: &K, value: &V) -> usize;
}

/// A scale that always return 0.
#[derive(Clone, Copy, Debug, Default)]
pub struct ZeroWeightScale;

impl<K, V> WeightScale<K, V> for ZeroWeightScale {
    #[inline]
    fn weight(&self, _: &K, _: &V) -> usize {
        0
    }
}