diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-16 11:47:58 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-01-04 12:45:52 +0100 |
commit | 0bbb6673e7ce703e470a3c2aad620ee5f009bc84 (patch) | |
tree | 844e95b50e2bc129403b679a6c5d63ff82940ad6 /src/util/crdt | |
parent | 53f71b3a57b3c1828292e26b7865d31e9bec44d6 (diff) | |
download | garage-0bbb6673e7ce703e470a3c2aad620ee5f009bc84.tar.gz garage-0bbb6673e7ce703e470a3c2aad620ee5f009bc84.zip |
Model changes
Diffstat (limited to 'src/util/crdt')
-rw-r--r-- | src/util/crdt/crdt.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/crdt/crdt.rs b/src/util/crdt/crdt.rs index 9b5f230d..2508d03b 100644 --- a/src/util/crdt/crdt.rs +++ b/src/util/crdt/crdt.rs @@ -28,6 +28,17 @@ pub trait Crdt { fn merge(&mut self, other: &Self); } +impl<T> Crdt for Option<T> +where + T: Eq, +{ + fn merge(&mut self, other: &Self) { + if self != other { + *self = None; + } + } +} + /// All types that implement `Ord` (a total order) can also implement a trivial CRDT /// defined by the merge rule: `a ⊔ b = max(a, b)`. Implement this trait for your type /// to enable this behavior. |