fixup minimum lru capacity

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-06-08 10:13:46 +02:00
parent 4121628d99
commit 1e7639bfc4
1 changed files with 1 additions and 1 deletions

View File

@ -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(),