dirtytype

Crates.iodirtytype
lib.rsdirtytype
version0.6.0
sourcesrc
created_at2023-04-14 08:14:20.688947
updated_at2024-11-28 00:01:40.186265
descriptionA marker of types being dirty for Rust
homepage
repository
max_upload_size
id839017
size6,090
SalsaGal (SalsaGal)

documentation

README

dirtytype

This is a library for marking fields as dirty, ie marking them when they are changed.

Example usage

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()));
    }
}
Commit count: 0

cargo fmt