summaryrefslogtreecommitdiffstats
path: root/src/dirty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dirty.rs')
-rw-r--r--src/dirty.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dirty.rs b/src/dirty.rs
new file mode 100644
index 0000000..fe6e4d1
--- /dev/null
+++ b/src/dirty.rs
@@ -0,0 +1,35 @@
+#[derive(PartialEq, Eq, Hash, Clone, Debug)]
+pub struct DirtyBit(bool);
+
+pub trait Dirtyable {
+ fn get_bit(&self) -> &DirtyBit;
+ fn get_bit_mut(&mut self) -> &mut DirtyBit;
+
+ fn is_dirty(&self) -> bool {
+ self.get_bit().0
+ }
+
+ fn set_dirty(&mut self) {
+ self.get_bit_mut().0 = true;
+ }
+ fn set_clean(&mut self) {
+ self.get_bit_mut().0 = false;
+ }
+}
+
+
+impl DirtyBit {
+ pub fn new() -> DirtyBit {
+ DirtyBit(false)
+ }
+}
+
+
+impl Dirtyable for DirtyBit {
+ fn get_bit(&self) -> &DirtyBit {
+ self
+ }
+ fn get_bit_mut(&mut self) -> &mut DirtyBit {
+ self
+ }
+}