cell-ref
This crate provides a Cell type (like the standard library’s
Cell) with methods for safely mutating and inspecting the
inner value by reference (with and with_mut).
For Copy types, this is implemented with get and
set, but through an extension trait, this crate
provides those same operations for types that are Default but not
Copy. A get method is also available for types that are both
Default and Clone.
This crate depends only on core, so it can be used inside no_std
environments.
Example
use ;
let c1 = new;
c1.with_mut;
assert!;
let c2 = new;
c2.with_mut; // Works even though `Vec` isn't `Copy`
assert_eq!;
let v = c2.get; // Clones the vector