| Crates.io | changed |
| lib.rs | changed |
| version | 0.1.2 |
| created_at | 2021-06-28 19:37:49.083863+00 |
| updated_at | 2021-07-03 22:04:42.783417+00 |
| description | Simple change detection |
| homepage | https://github.com/Hoidigan/changed |
| repository | https://github.com/Hoidigan/changed |
| max_upload_size | |
| id | 415852 |
| size | 6,245 |
Cd: A "smart pointer" that tracks changes to the data it owns.
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());
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.