[−][src]Struct lazy_init::Lazy
Lazy<T> is a lazily initialized synchronized holder type. You can think
of it as a LazyTransform where the initial type doesn't exist.
Implementations
impl<T> Lazy<T>[src]
pub fn new() -> Lazy<T>[src]
Construct a new, uninitialized Lazy<T>.
pub fn into_inner(self) -> Option<T>[src]
Unwrap the contained value, returning Some if the Lazy<T> has been initialized
or None if it has not.
impl<T> Lazy<T> where
T: Sync, [src]
T: Sync,
pub fn get_or_create<F>(&self, f: F) -> &T where
F: FnOnce() -> T, [src]
F: FnOnce() -> T,
Get a reference to the contained value, invoking f to create it
if the Lazy<T> is uninitialized. It is guaranteed that if multiple
calls to get_or_create race, only one will invoke its closure, and
every call will receive a reference to the newly created value.
The value stored in the Lazy<T> is immutable after the closure returns
it, so think carefully about what you want to put inside!
pub fn get(&self) -> Option<&T>[src]
Get a reference to the contained value, returning Some(ref) if the
Lazy<T> has been initialized or None if it has not. It is
guaranteed that if a reference is returned it is to the value inside
the Lazy<T>.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Lazy<T>
impl<T> Send for Lazy<T> where
T: Send,
T: Send,
impl<T> Sync for Lazy<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Lazy<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Lazy<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,