memcell

Crates.iomemcell
lib.rsmemcell
version0.1.1
sourcesrc
created_at2022-10-14 02:33:03.051421
updated_at2022-10-16 15:35:51.983575
descriptionA crate providing a MemoryCell struct, which stores a current and previous value.
homepage
repositoryhttps://github.com/ImajinDevon/memcell
max_upload_size
id687879
size8,654
Imajin (ImajinDevon)

documentation

README

memcell

Build and test status badge

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>,
}

Features

  • Full documentation
  • Constant 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));
}
Commit count: 12

cargo fmt