memcell 0.1.1

A crate providing a MemoryCell struct, which stores a current and previous value.
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented9 out of 11 items with examples
  • Size
  • Source code size: 8.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.43 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • zofiaclient/memcell
    8 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ImajinDevon

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));
}