aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-06 14:08:19 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-06 14:08:19 +0200
commit0ab21e780e8b944fb2e231c45b3777add27f368d (patch)
tree00db8413787b9ea132da45fcd70bb683a7b5470d
parenta77efd7ca6a02b9c668607e67efcaeeafd36a8bd (diff)
downloadgarage-0ab21e780e8b944fb2e231c45b3777add27f368d.tar.gz
garage-0ab21e780e8b944fb2e231c45b3777add27f368d.zip
Small syntax changes
-rw-r--r--src/db/lmdb_adapter.rs4
-rw-r--r--src/db/sled_adapter.rs4
-rw-r--r--src/garage/repair.rs26
-rw-r--r--src/table/data.rs5
-rw-r--r--src/table/gc.rs6
-rw-r--r--src/table/merkle.rs5
6 files changed, 18 insertions, 32 deletions
diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs
index 3d0edb38..04902d7f 100644
--- a/src/db/lmdb_adapter.rs
+++ b/src/db/lmdb_adapter.rs
@@ -10,9 +10,7 @@ use std::sync::{Arc, RwLock};
use heed::types::ByteSlice;
use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database};
-use crate::{
- Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter,
-};
+use crate::{Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter};
pub use heed;
diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs
index 489fae61..97fec2c7 100644
--- a/src/db/sled_adapter.rs
+++ b/src/db/sled_adapter.rs
@@ -9,9 +9,7 @@ use sled::transaction::{
UnabortableTransactionError,
};
-use crate::{
- Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter,
-};
+use crate::{Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter};
pub use sled;
diff --git a/src/garage/repair.rs b/src/garage/repair.rs
index 75828f24..17e14b8b 100644
--- a/src/garage/repair.rs
+++ b/src/garage/repair.rs
@@ -67,13 +67,12 @@ impl Repair {
let mut i = 0;
while !*must_exit.borrow() {
- let item_bytes = {
- let (k, v) = match self.garage.version_table.data.store.get_gt(pos)? {
- Some(pair) => pair,
- None => break,
- };
- pos = k;
- v
+ let item_bytes = match self.garage.version_table.data.store.get_gt(pos)? {
+ Some((k, v)) => {
+ pos = k;
+ v
+ }
+ None => break,
};
i += 1;
@@ -119,13 +118,12 @@ impl Repair {
let mut i = 0;
while !*must_exit.borrow() {
- let item_bytes = {
- let (k, v) = match self.garage.block_ref_table.data.store.get_gt(pos)? {
- Some(pair) => pair,
- None => break,
- };
- pos = k;
- v
+ let item_bytes = match self.garage.block_ref_table.data.store.get_gt(pos)? {
+ Some((k, v)) => {
+ pos = k;
+ v
+ }
+ None => break,
};
i += 1;
diff --git a/src/table/data.rs b/src/table/data.rs
index 64ca9f14..f6d49b4d 100644
--- a/src/table/data.rs
+++ b/src/table/data.rs
@@ -243,10 +243,7 @@ where
pub(crate) fn delete_if_equal(self: &Arc<Self>, k: &[u8], v: &[u8]) -> Result<bool, Error> {
let removed = self.store.db().transaction(|mut tx| {
- let remove = match tx.get(&self.store, k)? {
- Some(cur_v) if cur_v == v => true,
- _ => false,
- };
+ let remove = matches!(tx.get(&self.store, k)?, Some(cur_v) if cur_v == v => true);
if remove {
tx.remove(&self.store, k)?;
tx.insert(&self.merkle_todo, k, vec![])?;
diff --git a/src/table/gc.rs b/src/table/gc.rs
index 2a23f4cc..b9c589f4 100644
--- a/src/table/gc.rs
+++ b/src/table/gc.rs
@@ -383,10 +383,8 @@ impl GcTodoEntry {
pub(crate) fn remove_if_equal(&self, gc_todo_tree: &db::Tree) -> Result<(), Error> {
let key = self.todo_table_key();
gc_todo_tree.db().transaction(|mut tx| {
- let remove = match tx.get(gc_todo_tree, &key)? {
- Some(ov) if ov == self.value_hash.as_slice() => true,
- _ => false,
- };
+ let remove =
+ matches!(tx.get(gc_todo_tree, &key)? Some(ov) if ov == self.value_hash.as_slice());
if remove {
tx.remove(gc_todo_tree, &key)?;
}
diff --git a/src/table/merkle.rs b/src/table/merkle.rs
index 138f3ca3..e7f2442e 100644
--- a/src/table/merkle.rs
+++ b/src/table/merkle.rs
@@ -140,10 +140,7 @@ where
.transaction(|mut tx| self.update_item_rec(&mut tx, k, &khash, &key, new_vhash))?;
let deleted = self.data.merkle_todo.db().transaction(|mut tx| {
- let remove = match tx.get(&self.data.merkle_todo, k)? {
- Some(ov) if ov == vhash_by => true,
- _ => false,
- };
+ let remove = matches!(tx.get(&self.data.merkle_todo, k)?, Some(ov) if ov == vhash_by);
if remove {
tx.remove(&self.data.merkle_todo, k)?;
}