pub enum SetResult<'once_cell, T> {
Ok(&'once_cell T),
Initializing(T),
Initialized(&'once_cell T, T),
}
Expand description
The return value of OnceCell::set
.
Variants§
Ok(&'once_cell T)
The cell was succesfully initialized. Contains a reference to the new inner value.
Initializing(T)
The cell was in the process of being initialized by another task, and so could not be set.
Contains the value passed into OnceCell::set
.
Initialized(&'once_cell T, T)
The cell was already initialized. Contains both a reference to the initialized value and
the value passed into set
.
Implementations§
Source§impl<'once_cell, T> SetResult<'once_cell, T>
impl<'once_cell, T> SetResult<'once_cell, T>
Sourcepub fn ok(self) -> Result<&'once_cell T, T>
pub fn ok(self) -> Result<&'once_cell T, T>
Get a Result
over whether the given value was successfully inserted into the cell.
Sourcepub fn value(&self) -> Option<&'once_cell T>
pub fn value(&self) -> Option<&'once_cell T>
Retrieve a shared reference to the value inside the OnceCell
if one was present.
Sourcepub fn unwrap(self) -> &'once_cell T
pub fn unwrap(self) -> &'once_cell T
Panic if setting the value failed (the OnceCell
was being initialized or not empty).
Trait Implementations§
Source§impl<'once_cell, T: PartialEq> PartialEq for SetResult<'once_cell, T>
impl<'once_cell, T: PartialEq> PartialEq for SetResult<'once_cell, T>
impl<'once_cell, T: Copy> Copy for SetResult<'once_cell, T>
impl<'once_cell, T: Eq> Eq for SetResult<'once_cell, T>
impl<'once_cell, T> StructuralPartialEq for SetResult<'once_cell, T>
Auto Trait Implementations§
impl<'once_cell, T> Freeze for SetResult<'once_cell, T>where
T: Freeze,
impl<'once_cell, T> RefUnwindSafe for SetResult<'once_cell, T>where
T: RefUnwindSafe,
impl<'once_cell, T> Send for SetResult<'once_cell, T>
impl<'once_cell, T> Sync for SetResult<'once_cell, T>where
T: Sync,
impl<'once_cell, T> Unpin for SetResult<'once_cell, T>where
T: Unpin,
impl<'once_cell, T> UnwindSafe for SetResult<'once_cell, T>where
T: UnwindSafe + RefUnwindSafe,
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