fixup minimum lru capacity
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
4121628d99
commit
1e7639bfc4
|
@ -106,7 +106,7 @@ unsafe impl<K: Send, V: Send> Send for LruCache<K, V> {}
|
||||||
impl<K: std::cmp::Eq + std::hash::Hash + Copy, V> LruCache<K, V> {
|
impl<K: std::cmp::Eq + std::hash::Hash + Copy, V> LruCache<K, V> {
|
||||||
/// Create LRU cache instance which holds up to `capacity` nodes at once.
|
/// Create LRU cache instance which holds up to `capacity` nodes at once.
|
||||||
pub fn new(capacity: usize) -> Self {
|
pub fn new(capacity: usize) -> Self {
|
||||||
let capacity = capacity.min(1);
|
let capacity = capacity.max(1);
|
||||||
Self {
|
Self {
|
||||||
map: HashMap::with_capacity(capacity),
|
map: HashMap::with_capacity(capacity),
|
||||||
list: LinkedList::new(),
|
list: LinkedList::new(),
|
||||||
|
|
Loading…
Reference in New Issue