Module clone_cell::cell
source · Expand description
Shareable mutable containers.
When to use Cell
Cell::get
only requires T
to be PureClone
. This is useful
when working with with shared struct
s whose fields are of types Rc<T>
, Weak<T>
, Option<T: PureClone>
, etc.
Note that just because there can be any number of readers and writers to a Cell
does not
mean it is always a good pattern. In most cases, it may not make sense to have more than one
writer at a time. But the user can easily build zero-cost abstractions on top of a Cell
to
enforce this. For example, this may be useful when implementing the observer pattern.