Expand description
§What is a MemoryCell?
A MemoryCell
is a struct containing both a current and optional previous value.
§Definition
#[derive(Debug, Clone)]
pub struct MemoryCell<T> {
current: T,
last_val: Option<T>,
}
§Example usage
use memcell::MemoryCell;
let mut cell = MemoryCell::new(5_u32);
let new_value = 10;
cell.update(new_value);
assert_eq!(cell.current(), &10);
assert_eq!(cell.last(), Some(&5));
Structs§
- Memory
Cell - A cell containing a value ([T]), and the last (previous) value stored in the cell.