pub struct OnceLock<T> {
data: UnsafeCell<MaybeUninit<T>>,
once: Once,
}
🔬This is a nightly-only experimental API. (
kernel_sync_once
)Available on non-crate feature
use_std
only.Fields§
§data: UnsafeCell<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (
§kernel_sync_once
)once: Once
🔬This is a nightly-only experimental API. (
kernel_sync_once
)Implementations§
Source§impl<T> OnceLock<T>
impl<T> OnceLock<T>
pub const fn new() -> Self
🔬This is a nightly-only experimental API. (
kernel_sync_once
)pub fn get(&self) -> Option<&T>
🔬This is a nightly-only experimental API. (
kernel_sync_once
)pub fn get_mut(&mut self) -> Option<&mut T>
🔬This is a nightly-only experimental API. (
kernel_sync_once
)pub fn get_or_init(&self, f: impl FnOnce() -> T) -> &T
🔬This is a nightly-only experimental API. (
kernel_sync_once
)Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for OnceLock<T>
impl<T> !RefUnwindSafe for OnceLock<T>
impl<T> Unpin for OnceLock<T>where
T: Unpin,
impl<T> UnwindSafe for OnceLock<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more