len-caching-lock 0.1.1

Atomically cached len(), for use with collections contained in parking_lot Mutex and RwLock
Documentation
  • Coverage
  • 86.96%
    20 out of 23 items documented1 out of 21 items with examples
  • Size
  • Source code size: 12.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 610.62 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • litecreator

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());
	}
	```