pub struct LazyLock<T, F = fn() -> T> {
inner: LazyLock<T, F>,
}Expand description
A thread-safe, lazily-initialized value.
Constructed with a function (typically fn() -> T) so that it can be used
in static items via LazyLock::new, which is const.
§Examples
use o1_utils::lazy_lock::LazyLock;
static VALUE: LazyLock<u64> = LazyLock::new(|| 1 + 2);
assert_eq!(*VALUE, 3);Fields§
§inner: LazyLock<T, F>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> UnsafeUnpin for LazyLock<T, F>where
T: UnsafeUnpin,
F: UnsafeUnpin,
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