aboutsummaryrefslogtreecommitdiff
path: root/src/table/crdt/lww_map.rs
diff options
context:
space:
mode:
authorTrinity Pointard <trinity.pointard@gmail.com>2021-04-23 21:42:52 +0200
committerAlex Auvolat <alex@adnab.me>2021-05-03 22:11:41 +0200
commitf5a0cf0414fc3db7affcbe7ffcf4e251a2afd192 (patch)
tree12c225c9456f18d96cf8a587ce9a308f433da9e7 /src/table/crdt/lww_map.rs
parentf05bb111c2e7dd77f2b34b82892bbfa8e6a063c1 (diff)
downloadgarage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.tar.gz
garage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.zip
fix clippy warnings on table
Diffstat (limited to 'src/table/crdt/lww_map.rs')
-rw-r--r--src/table/crdt/lww_map.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/table/crdt/lww_map.rs b/src/table/crdt/lww_map.rs
index 7b372191..4ed26809 100644
--- a/src/table/crdt/lww_map.rs
+++ b/src/table/crdt/lww_map.rs
@@ -94,7 +94,7 @@ where
/// put_my_crdt_value(a);
/// ```
pub fn take_and_clear(&mut self) -> Self {
- let vals = std::mem::replace(&mut self.vals, vec![]);
+ let vals = std::mem::take(&mut self.vals);
Self { vals }
}
/// Removes all values from the map
@@ -113,10 +113,16 @@ where
pub fn items(&self) -> &[(K, u64, V)] {
&self.vals[..]
}
+
/// Returns the number of items in the map
pub fn len(&self) -> usize {
self.vals.len()
}
+
+ /// Returns true if the map is empty
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
}
impl<K, V> CRDT for LWWMap<K, V>
@@ -143,3 +149,13 @@ where
}
}
}
+
+impl<K, V> Default for LWWMap<K, V>
+where
+ K: Ord,
+ V: CRDT,
+{
+ fn default() -> Self {
+ Self::new()
+ }
+}