pub struct SyncOnceCell<T>(/* private fields */);Expand description
A cell that provides lazy one-time initialization that implements Sync and Send.
This module is a stub when no std is available to swap with std::sync::OnceLock.
Implementations§
Source§impl<T> SyncOnceCell<T>where
T: Debug,
impl<T> SyncOnceCell<T>where
T: Debug,
Sourcepub fn new() -> SyncOnceCell<T>
pub fn new() -> SyncOnceCell<T>
Create a new once.
Sourcepub fn initialized(value: T) -> SyncOnceCell<T>
pub fn initialized(value: T) -> SyncOnceCell<T>
Initialize the cell with a value.
Sourcepub fn get_or_init<F>(&self, f: F) -> &Twhere
F: FnOnce() -> T,
pub fn get_or_init<F>(&self, f: F) -> &Twhere
F: FnOnce() -> T,
Gets the contents of the cell, initializing it with f if the cell
was empty.
Trait Implementations§
Source§impl<T> Default for SyncOnceCell<T>where
T: Debug,
impl<T> Default for SyncOnceCell<T>where
T: Debug,
Source§fn default() -> SyncOnceCell<T>
fn default() -> SyncOnceCell<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<T> !Freeze for SyncOnceCell<T>
impl<T> RefUnwindSafe for SyncOnceCell<T>where
T: RefUnwindSafe + UnwindSafe,
impl<T> Send for SyncOnceCell<T>where
T: Send,
impl<T> Sync for SyncOnceCell<T>
impl<T> Unpin for SyncOnceCell<T>where
T: Unpin,
impl<T> UnwindSafe for SyncOnceCell<T>where
T: 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