Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

:timing
:sccache 1
:dep lru = "0.10.0"
Timing: true sccache: true
Loading...
use lru::LruCache;
use std::num::NonZeroUsize;
Loading...
let mut cache: LruCache<u64, &str> = LruCache::new(NonZeroUsize::new(2).unwrap());
Loading...
cache.put(1, "a")
None
Loading...
cache.put(2, "b")
None
Loading...
cache
LruCache { len: 2, cap: 2 }
Loading...
cache.put(2, "beta")
Some("b")
Loading...
cache.put(3, "hello")
None
Loading...
cache
LruCache { len: 2, cap: 2 }
Loading...
cache.get(&1)
None
Loading...
cache.get(&2)
Some("beta")
Loading...
cache.get(&3)
Some("hello")
Loading...