https://github.com/fightling/modify
https://github.com/fightling/modify
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fightling/modify
- Owner: fightling
- Created: 2024-02-16T11:00:08.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-07T19:26:32.000Z (almost 2 years ago)
- Last Synced: 2025-03-14T00:35:30.916Z (10 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Modify
[](https://github.com/fightling/modify/actions)
[](https://crates.io/crates/modify)
[](https://docs.rs/modify/)
[](https://deps.rs/repo/github/fightling/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
```rs
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);
```