Struct OnceBox
struct OnceBox<T> { ... }
A thread-safe cell which can be written to only once.
Implementations
impl<T> OnceBox<T>
const fn new() -> SelfCreates a new empty cell.
fn with_value(value: Box<T>) -> SelfCreates a new cell with the given value.
fn get(self: &Self) -> Option<&T>Gets a reference to the underlying value.
fn set(self: &Self, value: Box<T>) -> Result<(), Box<T>>Sets the contents of this cell to
value.Returns
Ok(())if the cell was empty andErr(value)if it was full.fn get_or_init<F>(self: &Self, f: F) -> &T where F: FnOnce() -> Box<T>Gets the contents of the cell, initializing it with
fif the cell was empty.If several threads concurrently run
get_or_init, more than onefcan be called. However, all threads will return the same value, produced by somef.fn get_or_try_init<F, E>(self: &Self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<Box<T>, E>Gets the contents of the cell, initializing it with
fif the cell was empty. If the cell was empty andffailed, an error is returned.If several threads concurrently run
get_or_init, more than onefcan be called. However, all threads will return the same value, produced by somef.
impl<T> Any for OnceBox<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for OnceBox<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for OnceBox<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for OnceBox<T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> Debug for OnceBox<T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T> Default for OnceBox<T>
fn default() -> Self
impl<T> Drop for OnceBox<T>
fn drop(self: &mut Self)
impl<T> Freeze for OnceBox<T>
impl<T> From for OnceBox<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> RefUnwindSafe for OnceBox<T>
impl<T> Send for OnceBox<T>
impl<T> ToOwned for OnceBox<T>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> Unpin for OnceBox<T>
impl<T> UnsafeUnpin for OnceBox<T>
impl<T> UnwindSafe for OnceBox<T>
impl<T, U> Into for OnceBox<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for OnceBox<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for OnceBox<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: Clone> Clone for OnceBox<T>
fn clone(self: &Self) -> Self