Struct OnceBool

struct OnceBool { ... }

A thread-safe cell which can be written to only once.

Implementations

impl OnceBool

const fn new() -> Self

Creates 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 and Err(()) if it was full.

fn get_or_init<F>(self: &Self, f: F) -> bool
where
    F: FnOnce() -> bool

Gets the contents of the cell, initializing it with f if the cell was empty.

If several threads concurrently run get_or_init, more than one f can be called. However, all threads will return the same value, produced by some f.

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 f if the cell was empty. If the cell was empty and f failed, an error is returned.

If several threads concurrently run get_or_init, more than one f can be called. However, all threads will return the same value, produced by some f.

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) -> T

Returns the argument unchanged.

impl<T, U> Into for OnceBool

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>