pub struct LazyWrap<T, F = fn() -> T> { /* private fields */ }
Expand description
A lazily initialised data wrapper that initialises itself on first access
Implementations§
Source§impl<T, F> LazyWrap<T, F>where
F: FnOnce() -> T,
impl<T, F> LazyWrap<T, F>where
F: FnOnce() -> T,
Sourcepub const fn new(init: F) -> Self
pub const fn new(init: F) -> Self
Creates a new uninitialised instance that will be initialised with the provided initialisation function.
Sourcepub fn ensure_initialised(this: &Self)
pub fn ensure_initialised(this: &Self)
Sourcepub fn is_initialised(this: &Self) -> bool
pub fn is_initialised(this: &Self) -> bool
Returns true or false, depending on if the value is initialised.
§Panics
Panics if the provided initialisation function panicked.
Sourcepub fn into_inner(this: Self) -> LazyWrapState<T, F>
pub fn into_inner(this: Self) -> LazyWrapState<T, F>
Fetch the value if its initialised, or return the initialisation function if it isn’t.
Sourcepub fn into_inner_initialised(this: Self) -> T
pub fn into_inner_initialised(this: Self) -> T
Ensures that the value is initialised, then returns the value.
Trait Implementations§
impl<T, F> RefUnwindSafe for LazyWrap<T, F>where
T: RefUnwindSafe,
F: UnwindSafe,
impl<T, F> Send for LazyWrap<T, F>
impl<T, F> Sync for LazyWrap<T, F>
impl<T, F> Unpin for LazyWrap<T, F>
impl<T, F> UnwindSafe for LazyWrap<T, F>where
T: UnwindSafe,
F: UnwindSafe,
Auto Trait Implementations§
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