pub(crate) struct OnceCell<T> {
once: Once,
value: UnsafeCell<MaybeUninit<T>>,
}
Fields§
§once: Once
§value: UnsafeCell<MaybeUninit<T>>
Implementations§
source§impl<T> OnceCell<T>
impl<T> OnceCell<T>
pub(crate) const fn new() -> Self
sourcepub(crate) fn get(&self, init: impl FnOnce() -> T) -> &T
pub(crate) fn get(&self, init: impl FnOnce() -> T) -> &T
Get the value inside this cell, initializing it using the provided function if necessary.
If the init
closure panics, then the OnceCell
is poisoned and all
future calls to get
will panic.
fn do_init(&self, init: impl FnOnce() -> T)
Trait Implementations§
impl<T: Send + Sync> Send for OnceCell<T>
impl<T: Send + Sync> Sync for OnceCell<T>
Auto Trait Implementations§
impl<T> !Freeze for OnceCell<T>
impl<T> !RefUnwindSafe for OnceCell<T>
impl<T> Unpin for OnceCell<T>where
T: Unpin,
impl<T> UnwindSafe for OnceCell<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