ref-stable-lru 0.2.2

An LRU Cache implementation with compile-time reference stability
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use ref_stable_lru::LruCache;
use std::num::NonZeroUsize;

fn main() {
    let mut cache: LruCache<&'static str, String> = LruCache::new(NonZeroUsize::new(2).unwrap());

    let x = cache.get(&"a").unwrap().as_str();
    // Should failed here, since `x` already mutually borrowed cache.
    let y = cache.get(&"b").unwrap().as_str();
    let z = cache.get(&"c").unwrap().as_str();
    [x, y, z].join(" ");
}