Skip to content

Commit

Permalink
Entry: modified finalizer added
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-kolarik committed May 7, 2024
1 parent abdf3ea commit a27b3e7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,22 @@ impl<'a, V: Copy> Value<'a, V> {
self.modified
}

pub fn set(&mut self, value: V) -> bool {
pub fn set(&mut self, value: V) {
self.value = value;
self.modified = true;
self.modified
}

pub fn set_neq(&mut self, value: V) -> bool
pub fn set_neq(&mut self, value: V)
where
V: PartialEq,
{
if &self.value != &value {
self.value = value;
self.modified = true;
}
}

pub fn modified(self) -> bool {
self.modified
}
}
Expand Down Expand Up @@ -282,20 +284,22 @@ impl<'a, V: Clone> ValueCloned<'a, V> {
self.modified
}

pub fn set(&mut self, value: V) -> bool {
pub fn set(&mut self, value: V) {
self.value = value;
self.modified = true;
self.modified
}

pub fn set_neq(&mut self, value: V) -> bool
pub fn set_neq(&mut self, value: V)
where
V: PartialEq,
{
if &self.value != &value {
self.value = value;
self.modified = true;
}
}

pub fn modified(self) -> bool {
self.modified
}
}
Expand Down

0 comments on commit a27b3e7

Please sign in to comment.