Struct OnceBool
struct OnceBool { ... }
A thread-safe cell which can be written to only once.
Implementations
impl OnceBool
const fn new() -> SelfCreates a new empty cell.
fn get(self: &Self) -> Option<bool>Gets the underlying value.
fn set(self: &Self, value: bool) -> Result<(), ()>Sets the contents of this cell to
value.Returns
Ok(())if the cell was empty andErr(())if it was full.fn get_or_init<F>(self: &Self, f: F) -> bool where F: FnOnce() -> boolGets 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<bool, E> where F: FnOnce() -> Result<bool, 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 Debug for OnceBool
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for OnceBool
fn default() -> OnceBool
impl Freeze for OnceBool
impl RefUnwindSafe for OnceBool
impl Send for OnceBool
impl Sync for OnceBool
impl Unpin for OnceBool
impl UnsafeUnpin for OnceBool
impl UnwindSafe for OnceBool
impl<T> Any for OnceBool
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for OnceBool
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for OnceBool
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for OnceBool
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for OnceBool
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 OnceBool
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for OnceBool
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>