Struct async_oncecell::Lazy [−][src]
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
Auto Trait Implementations
impl<T, F> !RefUnwindSafe for Lazy<T, F>
impl<T, F> Send for Lazy<T, F> where
F: Send,
T: Send,
F: Send,
T: Send,
impl<T, F> Sync for Lazy<T, F> where
F: Send,
T: Send + Sync,
F: Send,
T: Send + Sync,
impl<T, F> Unpin for Lazy<T, F> where
F: Unpin,
T: Unpin,
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for Lazy<T, F> where
F: UnwindSafe,
T: UnwindSafe,
F: 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,
pub 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.
pub 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>,