Expand description
This crate allows automatic caching of T.len()
with an api that
allows drop in replacement for parking_lot
Mutex
and RwLock
for most common use-cases.
This crate implements Len
for the following types:
std::collections::{VecDeque, LinkedList, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap}
§Example
extern crate len_caching_lock;
use len_caching_lock::LenCachingMutex;
fn main() {
let vec: Vec<i32> = Vec::new();
let len_caching_mutex = LenCachingMutex::new(vec);
assert_eq!(len_caching_mutex.lock().len(), len_caching_mutex.load_len());
len_caching_mutex.lock().push(0);
assert_eq!(1, len_caching_mutex.load_len());
}
Re-exports§
pub use mutex::LenCachingMutex;
pub use rwlock::LenCachingRwLock;
Modules§
Traits§
- Len
- Implement to allow a type with a len() method to be used
with
LenCachingMutex
orLenCachingRwLock