From c7d5c732442c5802058b46205d450d4620772b7b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 22 Dec 2021 09:57:02 +0100 Subject: [PATCH] Add must_use to some CRDT functions --- src/util/crdt/lww_map.rs | 1 + src/util/crdt/map.rs | 1 + src/util/crdt/mod.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/crdt/lww_map.rs b/src/util/crdt/lww_map.rs index f3a90591..1746c3cc 100644 --- a/src/util/crdt/lww_map.rs +++ b/src/util/crdt/lww_map.rs @@ -63,6 +63,7 @@ where /// /// However extracting the mutator on its own and only sending that on the network is very /// interesting as it is much smaller than the whole map. + #[must_use = "CRDT mutators are meant to be merged into a CRDT and not ignored."] pub fn update_mutator(&self, k: K, new_v: V) -> Self { let new_vals = match self.vals.binary_search_by(|(k2, _, _)| k2.cmp(&k)) { Ok(i) => { diff --git a/src/util/crdt/map.rs b/src/util/crdt/map.rs index 7553cd50..ad9a6e55 100644 --- a/src/util/crdt/map.rs +++ b/src/util/crdt/map.rs @@ -33,6 +33,7 @@ where /// This can be used to build a delta-mutator: /// when merged with another map, the value will be added or CRDT-merged if a previous /// value already exists. + #[must_use = "CRDT mutators are meant to be merged into a CRDT and not ignored."] pub fn put_mutator(k: K, v: V) -> Self { Self { vals: vec![(k, v)] } } diff --git a/src/util/crdt/mod.rs b/src/util/crdt/mod.rs index 6ba575ed..64f0984e 100644 --- a/src/util/crdt/mod.rs +++ b/src/util/crdt/mod.rs @@ -7,7 +7,7 @@ //! counter. Alice does +1 on her copy, she reads 1. Bob does +3 on his copy, he reads 3. Now, //! it is easy to merge their counters, order does not count: we always get 4. //! -//! Learn more about CRDT [on Wikipedia](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) +//! Learn more about CRDTs [on Wikipedia](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) mod bool; #[allow(clippy::module_inception)]