Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fightling/modify
https://github.com/fightling/modify
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fightling/modify
- Owner: fightling
- Created: 2024-02-16T11:00:08.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-07T19:26:32.000Z (10 months ago)
- Last Synced: 2024-12-01T23:20:31.504Z (about 1 month 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
[![Status](https://github.com/fightling/modify/actions/workflows/rust.yml/badge.svg)](https://github.com/fightling/modify/actions)
[![Crates.io](https://img.shields.io/crates/v/modify.svg)](https://crates.io/crates/modify)
[![Documentation](https://docs.rs/modify/badge.svg)](https://docs.rs/modify/)
[![Dependency status](https://deps.rs/repo/github/fightling/modify/status.svg)](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);
```