memcell

MemoryCell implementation. Lite, documented, ready.

What is a MemoryCell?

MemoryCell is a struct containing both a current and optional previous value.

GitHub workflow status

Definition

                #[derive(Debug, Clone)]
pub struct MemoryCell<T> {
    current: T,
    last_val: Option<T>,
}
            

Features

  • Fully documented
  • const methods
  • Lightweight
  • Zero dependencies
  • Pure Rust

Example Usage

    use memcell::MemoryCell;

fn main() {
    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));
}