pub struct LazyInit<T, Check: Policy = BasicCheck> { /* private fields */ }Expand description
A cell providing explicit, one-time initialization for a static value of
type T.
LazyInit allows storing types in static memory that require runtime
initialization. Accesses are validated according to the specified Policy
strategy.
Implementations§
Source§impl<T, Check: Policy> LazyInit<T, Check>
impl<T, Check: Policy> LazyInit<T, Check>
Sourcepub unsafe fn init(&'static self, value: T)
pub unsafe fn init(&'static self, value: T)
Moves the given value into the wrapped storage.
§Safety
The caller must ensure that initialization is serialized with respect to
any other access to this instance (i.e., that init does not race with
any concurrent reads or other initialization calls).
§Panics
Panics if the instance has already been initialized or is currently initializing.
Sourcepub unsafe fn init_pin<E>(
self: Pin<&'static Self>,
init: impl PinInit<T, E>,
) -> Result<(), E>
pub unsafe fn init_pin<E>( self: Pin<&'static Self>, init: impl PinInit<T, E>, ) -> Result<(), E>
Explicitly constructs the wrapped value in-place using a PinInit
initializer.
§Safety
The caller must ensure that initialization is serialized with respect to
any other access to this instance (i.e., that init_pin does not race
with any concurrent reads or other initialization calls).
§Panics
Panics if the instance has already been initialized or is currently initializing.
Sourcepub const unsafe fn get_unchecked(&self) -> &T
pub const unsafe fn get_unchecked(&self) -> &T
Returns a reference to the wrapped value without checking initialization state.
§Safety
The caller must ensure that the instance has indeed been initialized.
Trait Implementations§
Source§impl<T, Check: CheckedPolicy> Deref for LazyInit<T, Check>
impl<T, Check: CheckedPolicy> Deref for LazyInit<T, Check>
impl<T: Send, Check: Policy> Send for LazyInit<T, Check>where
Check::State: Send,
impl<T: Sync, Check: Policy> Sync for LazyInit<T, Check>
Auto Trait Implementations§
impl<T, Check = BasicCheck> !Freeze for LazyInit<T, Check>
impl<T, Check = BasicCheck> !RefUnwindSafe for LazyInit<T, Check>
impl<T, Check> Unpin for LazyInit<T, Check>
impl<T, Check> UnsafeUnpin for LazyInit<T, Check>
impl<T, Check> UnwindSafe for LazyInit<T, Check>
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
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read more