pub struct LazyLock<T, F = fn() -> T> { /* private fields */ }
Expand description
Wrapper for std::sync::LazyLock
This wrapper participates in cycle detection like all other primitives in this crate. It should only be possible to encounter cycles when acquiring mutexes in the initialisation function.
§Examples
use tracing_mutex::stdsync::tracing::LazyLock;
static LOCK: LazyLock<i32> = LazyLock::new(|| {
println!("Hello, world!");
42
});
// This should print "Hello, world!"
println!("{}", *LOCK);
// This should not.
println!("{}", *LOCK);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T, F = fn() -> T> !Freeze for LazyLock<T, F>
impl<T, F> RefUnwindSafe for LazyLock<T, F>
impl<T, F> Send for LazyLock<T, F>
impl<T, F> Sync for LazyLock<T, F>
impl<T, F> Unpin for LazyLock<T, F>
impl<T, F> UnwindSafe for LazyLock<T, F>where
T: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more