Struct lazycell::LazyCell
[−]
[src]
pub struct LazyCell<T> { /* fields omitted */ }
A lazily filled Cell
, with frozen contents.
Methods
impl<T> LazyCell<T>
[src]
pub fn new() -> LazyCell<T>
[src]
Creates a new, empty, LazyCell
.
pub fn fill(&self, value: T) -> Result<(), T>
[src]
Put a value into this cell.
This function will return Err(value)
is the cell is already full.
pub fn filled(&self) -> bool
[src]
Test whether this cell has been previously filled.
pub fn borrow(&self) -> Option<&T>
[src]
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 borrow_mut(&mut self) -> Option<&mut T>
[src]
Borrows the contents of this lazy cell mutably 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 borrow_with<F: FnOnce() -> T>(&self, f: F) -> &T
[src]
Borrows the contents of this lazy cell for the duration of the cell itself.
If the cell has not yet been filled, the cell is first filled using the function provided.
Panics
Panics if the cell becomes filled as a side effect of f
.
pub fn try_borrow_with<E, F>(&self, f: F) -> Result<&T, E> where
F: FnOnce() -> Result<T, E>,
[src]
F: FnOnce() -> Result<T, E>,
Same as borrow_with
, but allows the initializing function to fail.
Panics
Panics if the cell becomes filled as a side effect of f
.
pub fn into_inner(self) -> Option<T>
[src]
Consumes this LazyCell
, returning the underlying value.
impl<T: Copy> LazyCell<T>
[src]
pub fn get(&self) -> Option<T>
[src]
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 LazyCell<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more