Struct std::cell::Cell

pub struct Cell<T> {
    priv value: Option<T>,
}

Methods

impl<T> Cell<T>

fn new(value: T) -> Cell<T>

Creates a new full cell with the given value.

fn new_empty() -> Cell<T>

Creates a new empty cell with no value inside.

fn take(&self) -> T

Yields the value, failing if the cell is empty.

fn take_opt(&self) -> Option<T>

Yields the value if the cell is full, or None if it is empty.

fn put_back(&self, value: T)

Returns the value, failing if the cell is full.

fn is_empty(&self) -> bool

Returns true if the cell is empty and false if the cell is full.

fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R

Calls a closure with a reference to the value.

fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R

Calls a closure with a mutable reference to the value.

Trait Implementations

impl<T: Clone> Clone for Cell<T>

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

Returns a copy of the value. The contents of owned pointers are copied to maintain uniqueness, while the contents of managed pointers are not copied.

impl<T: DeepClone> DeepClone for Cell<T>

fn deep_clone(&self) -> Cell<T>

Return a deep copy of the value. Unlike Clone, the contents of shared pointer types are copied.

impl<T: Eq> Eq for Cell<T>

fn eq(&self, __arg_0: &Cell<T>) -> bool

fn ne(&self, __arg_0: &Cell<T>) -> bool