Crates.io | lazy_mut |
lib.rs | lazy_mut |
version | |
source | src |
created_at | 2018-03-11 19:08:35.84431+00 |
updated_at | 2025-01-20 16:40:57.723569+00 |
description | Alternative to LazyLock |
homepage | |
repository | https://github.com/Vrtgs/lazy-mut |
max_upload_size | |
id | 55035 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
The LazyMut library provides a synchronization primitive for deferred initialization with a single synchronization step. It is especially useful for scenarios where initialization logic is expensive or should be deferred until first use. The library supports multiple locking backends, including std, parking_lot, and spin (depending on feature flags). This library is #![no_std] compatible, making it suitable for embedded systems and environments where the standard library is unavailable.
std
, parking_lot
, or spin
) depending on enabled features.use lazy_mut::LazyMut;
static VICTOR: LazyMut<Vec<u8>> = LazyMut::new(|| vec![1, 2, 3]);
fn main() {
VICTOR.get_mut().push(10);
VICTOR.try_get_mut().unwrap().push(10);
assert_eq!(*VICTOR.get_mut(), [1, 2, 3, 10 ,10])
}