KVCell
contains an optional value and provides access by key in two
flavors:
fn take_or_drop(&mut self, key: &K) -> Option<T>
fn take_or_keep(&mut self, key: &K) -> Option<T>
Both return Some
value only if provided key matches the contained one.
The behavior differs when the provided key doesn't match:
take_or_drop
always leaves the cell empty. It supersedes CachedCell
and copies its behavior.
take_or_keep
retains contained value. It's a replacement for JointStateLatch
.