changed 0.1.2

Simple change detection
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented7 out of 8 items with examples
  • Size
  • Source code size: 6.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 317.95 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Hoidigan/changed
    4 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Hoidigan

Cd: A "smart pointer" that tracks changes to the data it owns.

Usage

use changed::Cd;

// Create the change tracker with an i32
let mut test: Changed<i32> = Changed::new(20);

// Mutate it (calling deref_mut through the *)
*test += 5;

// changed() reports whether or not it was changed
assert!(test.changed());

// Reset it the tracker back to false
test.reset();

// Read the data
assert_eq!(*test, 25);

// That didn't trip the change detection!
assert!(!test.changed());

How it works

Technically, it doesn't track changes. It tracks calls to deref_mut() so it is entirely possible to call deref_mut() and not change it, giving a false positive.

Along with that, there is a function to mutate a Cd without tripping change detection.