Model changes

This commit is contained in:
Alex Auvolat
2021-12-16 11:47:58 +01:00
parent 53f71b3a57
commit 0bbb6673e7
14 changed files with 119 additions and 57 deletions
+11
View File
@@ -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.