pub struct Once<T> { /* private fields */ }
Expand description
A synchronization primitive which initializes a value lazily, once. Since this also includes a
value, it is a bit more like Once
from parking_lot
or spin
.
Implementations§
Source§impl<T> Once<T>
impl<T> Once<T>
pub const fn new() -> Self
pub const fn uninitialized() -> Self
pub const fn initialized(value: T) -> Self
pub fn initialize(&self, value: T) -> Result<(), T>
pub fn try_call_once<'a, F>(&'a self, init: F) -> Result<&'a T, F>where
F: FnOnce() -> T,
pub fn call_once<'a, F>(&'a self, init: F) -> &'a Twhere
F: FnOnce() -> T,
pub fn wait<'a>(&'a self) -> &'a T
pub fn try_get<'a>(&'a self) -> Option<&'a T>
pub fn state(&self) -> OnceState
Trait Implementations§
impl<T: RefUnwindSafe> RefUnwindSafe for Once<T>
impl<T: Send + Sync> Send for Once<T>
impl<T: Send + Sync> Sync for Once<T>
impl<T: UnwindSafe> UnwindSafe for Once<T>
Auto Trait Implementations§
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