Skip to main content

CellExt

Trait CellExt 

Source
pub trait CellExt<T>: Sealed {
    // Required methods
    fn get(&self) -> T
       where T: Clone + Default;
    fn with<F, R>(&self, f: F) -> R
       where T: Default,
             F: FnOnce(&T) -> R;
    fn with_mut<F, R>(&self, f: F) -> R
       where T: Default,
             F: FnOnce(&mut T) -> R;
}
Expand description

Provides additional methods for non-Copy types.

Required Methods§

Source

fn get(&self) -> T
where T: Clone + Default,

Gets the value held by the cell.

Source

fn with<F, R>(&self, f: F) -> R
where T: Default, F: FnOnce(&T) -> R,

Calls f with a reference to the contents of the cell.

Source

fn with_mut<F, R>(&self, f: F) -> R
where T: Default, F: FnOnce(&mut T) -> R,

Calls f with a mutable reference to the contents of the cell.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> CellExt<T> for Cell<T>