Struct std::cell::Cell
pub struct Cell<T> { // some fields omitted }
A mutable memory location that admits only Copy
data.
Methods
impl<T: Copy> Cell<T>
fn new(value: T) -> Cell<T>
Creates a new Cell
containing the given value.
fn get(&self) -> T
Returns a copy of the contained value.
fn set(&self, value: T)
Sets the contained value.
Trait Implementations
impl<T: Copy> 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.
fn clone_from(&mut self, source: &Self)
Perform copy-assignment from source
.
a.clone_from(&b)
is equivalent to a = b.clone()
in functionality,
but can be overridden to reuse the resources of a
to avoid unnecessary
allocations.