[][src]Struct lazy_init::Lazy

pub struct Lazy<T> { /* fields omitted */ }

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>[src]

pub fn get_or_create<F>(&self, f: F) -> &T where
    F: FnOnce() -> T, 
[src]

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

impl<T: Clone> Clone for Lazy<T>[src]

impl<T> Debug for Lazy<T> where
    T: Debug
[src]

impl<T> Default for Lazy<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Lazy<T>[src]

impl<T> Send for Lazy<T> where
    T: Send
[src]

impl<T> Sync for Lazy<T> where
    T: Send + Sync
[src]

impl<T> Unpin for Lazy<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Lazy<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.