| Crates.io | modify |
| lib.rs | modify |
| version | 0.1.3 |
| created_at | 2024-02-16 11:08:47.201756+00 |
| updated_at | 2024-03-07 19:26:55.922189+00 |
| description | A library to track changes of a value. |
| homepage | |
| repository | https://github.com/fightling/modify.git |
| max_upload_size | |
| id | 1142340 |
| size | 5,671 |
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.
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);