[−][src]Struct lazycell::AtomicLazyCell
A lazily filled and thread-safe Cell
, with frozen contents.
Methods
impl<T> AtomicLazyCell<T>
[src]
impl<T> AtomicLazyCell<T>
pub const NONE: Self
[src]
An empty AtomicLazyCell
.
pub fn new() -> AtomicLazyCell<T>
[src]
pub fn new() -> AtomicLazyCell<T>
Creates a new, empty, AtomicLazyCell
.
pub fn fill(&self, t: T) -> Result<(), T>
[src]
pub fn fill(&self, t: T) -> Result<(), T>
Put a value into this cell.
This function will return Err(value)
is the cell is already full.
pub fn replace(&mut self, value: T) -> Option<T>
[src]
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.
pub fn filled(&self) -> bool
[src]
pub fn filled(&self) -> bool
Test whether this cell has been previously filled.
pub fn borrow(&self) -> Option<&T>
[src]
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.
pub fn into_inner(self) -> Option<T>
[src]
pub fn into_inner(self) -> Option<T>
Consumes this LazyCell
, returning the underlying value.
impl<T: Copy> AtomicLazyCell<T>
[src]
impl<T: Copy> AtomicLazyCell<T>
pub fn get(&self) -> Option<T>
[src]
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
impl<T: Debug> Debug for AtomicLazyCell<T>
[src]
impl<T: Debug> Debug for AtomicLazyCell<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Send> Send for AtomicLazyCell<T>
[src]
impl<T: Send> Send for AtomicLazyCell<T>
impl<T: Sync + Send> Sync for AtomicLazyCell<T>
[src]
impl<T: Sync + Send> Sync for AtomicLazyCell<T>
impl<T: Default> Default for AtomicLazyCell<T>
[src]
impl<T: Default> Default for AtomicLazyCell<T>
fn default() -> AtomicLazyCell<T>
[src]
fn default() -> AtomicLazyCell<T>
Returns the "default value" for a type. Read more
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more