Crate dirtytype

source ·
Expand description

dirtytype

This is a library for marking fields as dirty, ie marking them when they are changed. It is primarily concerned with the Dirty enum.

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:

use dirtytype::Dirty;

struct BufferData<T> {
    data: Dirty<T>,
    buffer: Buffer,
}

impl<T: Default> BufferData<T> {
    fn update(&mut self) {
        if let Some(value) = self.data.dirty() {
            self.buffer.update(value);
        }
    }
}

Enums

  • A struct that stores a T and marks if the data inside has been modified.