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: Debug> SyncOnceCell<T>
impl<T: Debug> SyncOnceCell<T>
Sourcepub fn initialized(value: T) -> Self
pub fn initialized(value: T) -> Self
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§
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