lazymut 0.2.0

Similar to LazyCell, but use &mut self to get or initialization
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented6 out of 7 items with examples
  • Size
  • Source code size: 7.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 849.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • A4-Tacks/lazymut-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • A4-Tacks

Similar to [std::cell::LazyCell], but use &mut self to get or initialization

Suitable for being wrapped in a Mutex

Examples

use lazymut::LazyMut;
use std::sync::Mutex;

static FOO: Mutex<LazyMut<Vec<i32>>> = Mutex::new(LazyMut::new(|| {
    vec![1]
}));

let mut lock = FOO.lock().unwrap();
assert_eq!(lock.get(), &mut vec![1]);
lock.get().push(2);
assert_eq!(lock.get(), &mut vec![1, 2]);