Tracking issue for Cell::update · Issue #50186 · rust-lang/rust (original) (raw)
This issue tracks the cell_update
feature.
The feature adds Cell::update
, which allows one to more easily modify the inner value.
For example, instead of c.set(c.get() + 1)
now you can just do c.update(|x| x + 1)
:
let c = Cell::new(5); let new = c.update(|x| x + 1);
assert_eq!(new, 6); assert_eq!(c.get(), 6);