Crates.io | dirtytype |
lib.rs | dirtytype |
version | |
source | src |
created_at | 2023-04-14 08:14:20.688947+00 |
updated_at | 2025-05-07 09:44:26.790672+00 |
description | A marker of types being dirty for Rust |
homepage | |
repository | |
max_upload_size | |
id | 839017 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
dirtytype
This is a library for marking fields as dirty, ie marking them when they are changed.
Dirty
can be used create a type that stores a copy of data and writes it to some sort of buffer when the data is modified:
# struct Buffer {}
# impl Buffer {
# fn update<T>(&mut self, value: T) {}
# }
use dirtytype::Dirty;
struct BufferData<T> {
data: Dirty<T>,
buffer: Buffer,
}
impl<T: Default + Clone> BufferData<T> {
fn update(&mut self) {
self.data.clean(|value| self.buffer.update(value.clone()));
}
}