pub fn insert(&mut self, k: K, v: V) -> Option<V> {
        self.used += v.size();
        let old = self.map.insert(k, v);
        if let Some(ref old_val) = old {
            self.used -= old_val.size()
        }
        while self.used() > self.capacity() {
            self.remove_lru();
        }
        old
    }
/// Inserts a key-value pair into the cache. If the key already existed, the old value is
/// returned.
///
/// # Examples
///
/// ```
/// use lru_size_cache::LruSizeCache;
///
/// let mut cache = LruSizeCache::new(2);
///
/// cache.insert(1, "a");
/// cache.insert(2, "b");
/// assert_eq!(cache.get(&1), Some(&"a"));
/// assert_eq!(cache.get(&2), Some(&"b"));
/// ```
Inserts a key-value pair into the cache. If the key already existed, the old value is
returned.
Inserts a key - value pair into the cache . If the key already existed the old value is returned .
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
        self.used += v.size();
        let old = self.map.insert(k, v);
        if let Some(ref old_val) = old {
            self.used -= old_val.size()
        }
        while self.used() > self.capacity() {
            self.remove_lru();
        }
        old
    }
pub fn insert ( & mut self , k : K , v : V ) -> Option < V > { self . used += v . size ( ) ; let old = self . map . insert ( k , v ) ; if let Some ( ref old_val ) = old { self . used -= old_val . size ( ) } while self . used ( ) > self . capacity ( ) { self . remove_lru ( ) ; } old }
Inserts a key-value pair into the cache.
Inserts a key - value pair into the cache .
&mut self
k
K
v
V
&mut self
k
K
v
V
examples
```
use lru_size_cache::LruSizeCache.

let mut cache = LruSizeCache::new(2).


` ` ` use lru_size_cache :: LruSizeCache . let mut cache = LruSizeCache :: new ( 2 ) .