Struct async_oncecell::Lazy[][src]

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

Lazy cell which is only instantiated upon first retreival of contained value

Implementations

impl<T, F> Lazy<T, F>[src]

pub fn new(f: F) -> Self[src]

Creates a new Lazy with the given instantiator.

Example

let lazy = Lazy::new(async {
    0 // Expensive calculation    
});
assert_eq!(lazy.get().await, &0);

impl<T, F: Future<Output = T>> Lazy<T, F>[src]

pub async fn get(&self) -> &T[src]

Retreives the contents of the Lazy. If not instantiated, the instantiator block will be executed first.

Trait Implementations

impl<T: Debug, F> Debug for Lazy<T, F>[src]

Auto Trait Implementations

impl<T, F> !RefUnwindSafe for Lazy<T, F>

impl<T, F> Send for Lazy<T, F> where
    F: Send,
    T: Send

impl<T, F> Sync for Lazy<T, F> where
    F: Send,
    T: Send + Sync

impl<T, F> Unpin for Lazy<T, F> where
    F: Unpin,
    T: Unpin

impl<T, F> UnwindSafe for Lazy<T, F> where
    F: UnwindSafe,
    T: UnwindSafe

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, 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.