### Basic LRU Map Usage with Length Limit Source: https://github.com/koute/schnellru/blob/master/README.md Demonstrates creating an LRU map with a fixed length capacity, inserting elements, accessing them to change their order, and observing automatic eviction when the capacity is exceeded. ```rust use schnellru::{LruMap, ByLength}; let mut map = LruMap::new(ByLength::new(3)); // Insert three elements. map.insert(1, "one"); map.insert(2, "two"); map.insert(3, "three"); assert_eq!(map.len(), 3); // They're ordered according to which one was inserted last. let mut iter = map.iter(); assert_eq!(iter.next().unwrap(), (&3, &"three")); assert_eq!(iter.next().unwrap(), (&2, &"two")); assert_eq!(iter.next().unwrap(), (&1, &"one")); // Access the least recently inserted one. assert_eq!(*map.get(&1).unwrap(), "one"); // Now the order's changed. // The element we've accessed was moved to the front. let mut iter = map.iter(); assert_eq!(iter.next().unwrap(), (&1, &"one")); assert_eq!(iter.next().unwrap(), (&3, &"three")); assert_eq!(iter.next().unwrap(), (&2, &"two")); // Insert a fourth element. // This will automatically pop the least recently accessed one. map.insert(4, "four"); // Still the same number of elements. assert_eq!(map.len(), 3); // And this is the one which was removed. assert!(map.peek(&2).is_none()); // And here's the new order. let mut iter = map.iter(); assert_eq!(iter.next().unwrap(), (&4, &"four")); assert_eq!(iter.next().unwrap(), (&1, &"one")); assert_eq!(iter.next().unwrap(), (&3, &"three")); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.