lazy-exclusive
a global container type (like LazyLock
) with runtime-checked mutability. can be used for static
variables
let lazy = new;
let mut lock = lazy.get.unwrap; // Mut<'_, i32>
let mut mutref = &mut *lock; // &mut i32
println!; // will print 20
let opt = lazy.get; // is none because lock still exists
add this crate to your code like this:
use-locks
enable the use-locks
feature for the crate to use system-implemented locks.
let start = now;
let five_seconds = from_secs;
static SHARED: = new;
let mut lock = SHARED.get.unwrap;
spawn;
assert_eq!;
let new_lock = SHARED.wait;
assert_eq!;
assert!;
no_std support
this crate supports no_std, which can be used by disabling default-features
[]
= { = "1.0", = false }
you can enable use-locks
with no_std
like this
[]
= { = "1.0", = false, = ["use-locks"] }
note that this is not guaranteed to work properly