From bdff08776bebe55ac124172d506d6cf08f75bd88 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Fri, 21 Nov 2025 23:29:22 +0100 Subject: remove OptionTracker --- src/util/option_tracker.rs | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/util/option_tracker.rs (limited to 'src/util/option_tracker.rs') diff --git a/src/util/option_tracker.rs b/src/util/option_tracker.rs deleted file mode 100644 index 3c19ee5..0000000 --- a/src/util/option_tracker.rs +++ /dev/null @@ -1,43 +0,0 @@ -pub struct OptionTracker { - inner: Option, - dirty: bool, -} - -/// Tracks changes to an inner Option. Any change using `set` will cause the -/// tracker to be marked as dirty, unless both the current and new value are -/// `None`. This should be used when changes from `Some(something)` to -/// `Some(something_different)` are rare, or when comparing inner values is more -/// expensive than performing an update which will mark the tracker as clean. -impl OptionTracker { - pub fn new(inner: Option) -> Self { - Self { inner, dirty: true } - } - - pub fn get(&self) -> &Option { - &self.inner - } - - pub fn set(&mut self, value: Option) { - match (&self.inner, &value) { - (None, None) => {} - _ => self.dirty = true, - } - - self.inner = value; - } - - pub fn is_dirty(&self) -> bool { - self.dirty - } - - /// Marks the tracker as clean. - pub fn reset(&mut self) { - self.dirty = false; - } -} - -impl Default for OptionTracker { - fn default() -> Self { - Self::new(Option::default()) - } -} -- cgit 1.4.1