Struct lazycell::LazyCell[][src]

pub struct LazyCell<T> { /* fields omitted */ }

A lazily filled Cell, with mutable contents.

A LazyCell is completely frozen once filled, unless you have &mut access to it, in which case LazyCell::borrow_mut may be used to mutate the contents.

Methods

impl<T> LazyCell<T>
[src]

Creates a new, empty, LazyCell.

Put a value into this cell.

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

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.

Test whether this cell has been previously filled.

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.

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.

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.

Borrows the contents of this LazyCell mutably 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.

Same as borrow_with, but allows the initializing function to fail.

Panics

Panics if the cell becomes filled as a side effect of f.

Same as borrow_mut_with, but allows the initializing function to fail.

Panics

Panics if the cell becomes filled as a side effect of f.

Consumes this LazyCell, returning the underlying value.

impl<T: Copy> LazyCell<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]

Formats the value using the given formatter. Read more

impl<T: Default> Default for LazyCell<T>
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl<T> Send for LazyCell<T> where
    T: Send

impl<T> !Sync for LazyCell<T>