pub struct OnceCell<T> { /* private fields */ }
Expand description
A value that can only be written once.
Implementations§
source§impl<T> OnceCell<T>
impl<T> OnceCell<T>
sourcepub async fn get_or_try_init<E>(
&self,
setter: impl Future<Output = Result<T, E>>
) -> Result<&T, E>
pub async fn get_or_try_init<E>( &self, setter: impl Future<Output = Result<T, E>> ) -> Result<&T, E>
Get the value of the cell or try to initialize it.
sourcepub async fn get_or_init(&self, setter: impl Future<Output = T>) -> &T
pub async fn get_or_init(&self, setter: impl Future<Output = T>) -> &T
Get the value of the cell or initialize it.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for OnceCell<T>
impl<T> !Send for OnceCell<T>
impl<T> !Sync for OnceCell<T>
impl<T> Unpin for OnceCell<T>where T: Unpin,
impl<T> !UnwindSafe for OnceCell<T>
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