From 0bbb6673e7ce703e470a3c2aad620ee5f009bc84 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 16 Dec 2021 11:47:58 +0100 Subject: Model changes --- src/util/crdt/crdt.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/util') 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 Crdt for Option +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. -- cgit v1.2.3