aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-22 09:57:02 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:47:28 +0100
commitc7d5c732442c5802058b46205d450d4620772b7b (patch)
tree8da97b3464d308b0ad4130820c712dd5c6ecd786
parentb76d0580a03c38d901a2b3d19e7c6ede6b0d09a7 (diff)
downloadgarage-c7d5c732442c5802058b46205d450d4620772b7b.tar.gz
garage-c7d5c732442c5802058b46205d450d4620772b7b.zip
Add must_use to some CRDT functions
-rw-r--r--src/util/crdt/lww_map.rs1
-rw-r--r--src/util/crdt/map.rs1
-rw-r--r--src/util/crdt/mod.rs2
3 files changed, 3 insertions, 1 deletions
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)]