4 releases
0.1.3 | Mar 7, 2024 |
---|---|
0.1.2 | Feb 16, 2024 |
0.1.1 | Feb 16, 2024 |
0.1.0 | Feb 16, 2024 |
#4 in #modified
248 downloads per month
6KB
77 lines
Modify
Attach a modified flag to a value and whenever the value is accessed via get_mut()
this flag will be set until saved()
is called.
Technical implements Deref
and DerefMut
to access the value.
Example
use crate::modify::*;
// create new Modify with a 42 in it
let mut value = Modify::new(42);
assert_eq!(value.is_modified(), false);
// set the value to 43 and check modified flag
*value = 43;
assert_eq!(value.is_modified(), true);
// reset modified flag check modified flag again
value.saved();
assert_eq!(value.is_modified(), false);
Dependencies
~0.7–1.5MB
~33K SLoC