lazycell

Struct AtomicLazyCell

Source
pub struct AtomicLazyCell<T> { /* private fields */ }
Expand description

A lazily filled and thread-safe Cell, with frozen contents.

Implementations§

Source§

impl<T> AtomicLazyCell<T>

Source

pub const NONE: Self = _

An empty AtomicLazyCell.

Source

pub fn new() -> AtomicLazyCell<T>

Creates a new, empty, AtomicLazyCell.

Source

pub fn fill(&self, t: T) -> Result<(), T>

Put a value into this cell.

This function will return Err(value) if the cell is already full.

Source

pub fn replace(&mut self, value: T) -> Option<T>

Put a value into this cell.

Note that this function is infallible but requires &mut self. By requiring &mut self we’re guaranteed that no active borrows to this cell can exist so we can always fill in the value. This may not always be usable, however, as &mut self may not be possible to borrow.

§Return value

This function returns the previous value, if any.

Source

pub fn filled(&self) -> bool

Test whether this cell has been previously filled.

Source

pub fn borrow(&self) -> Option<&T>

Borrows the contents of this lazy cell for the duration of the cell itself.

This function will return Some if the cell has been previously initialized, and None if it has not yet been initialized.

Source

pub fn into_inner(self) -> Option<T>

Consumes this LazyCell, returning the underlying value.

Source§

impl<T: Copy> AtomicLazyCell<T>

Source

pub fn get(&self) -> Option<T>

Returns a copy of the contents of the lazy cell.

This function will return Some if the cell has been previously initialized, and None if it has not yet been initialized.

Trait Implementations§

Source§

impl<T: Clone> Clone for AtomicLazyCell<T>

Source§

fn clone(&self) -> AtomicLazyCell<T>

Create a clone of this AtomicLazyCell

If self has not been initialized, returns an uninitialized AtomicLazyCell otherwise returns an AtomicLazyCell already initialized with a clone of the contents of self.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for AtomicLazyCell<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for AtomicLazyCell<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Send> Send for AtomicLazyCell<T>

Source§

impl<T: Sync + Send> Sync for AtomicLazyCell<T>

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicLazyCell<T>

§

impl<T> !RefUnwindSafe for AtomicLazyCell<T>

§

impl<T> Unpin for AtomicLazyCell<T>
where T: Unpin,

§

impl<T> UnwindSafe for AtomicLazyCell<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.