Fix clippy

This commit is contained in:
Alex 2022-06-06 15:10:33 +02:00
parent a65049db8f
commit c56d858834
Signed by: lx
GPG key ID: 0E496D15096376BE
2 changed files with 9 additions and 11 deletions

View file

@ -101,7 +101,7 @@ impl IDb for LmdbDb {
let tree = self.get_tree(tree)?; let tree = self.get_tree(tree)?;
let tx = self.db.read_txn()?; let tx = self.db.read_txn()?;
let val = tree.get(&tx, &key)?; let val = tree.get(&tx, key)?;
match val { match val {
None => Ok(None), None => Ok(None),
Some(v) => Ok(Some(v.to_vec())), Some(v) => Ok(Some(v.to_vec())),
@ -111,7 +111,7 @@ impl IDb for LmdbDb {
fn remove(&self, tree: usize, key: &[u8]) -> Result<bool> { fn remove(&self, tree: usize, key: &[u8]) -> Result<bool> {
let tree = self.get_tree(tree)?; let tree = self.get_tree(tree)?;
let mut tx = self.db.write_txn()?; let mut tx = self.db.write_txn()?;
let deleted = tree.delete(&mut tx, &key)?; let deleted = tree.delete(&mut tx, key)?;
tx.commit()?; tx.commit()?;
Ok(deleted) Ok(deleted)
} }
@ -125,7 +125,7 @@ impl IDb for LmdbDb {
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> { fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
let tree = self.get_tree(tree)?; let tree = self.get_tree(tree)?;
let mut tx = self.db.write_txn()?; let mut tx = self.db.write_txn()?;
tree.put(&mut tx, &key, &value)?; tree.put(&mut tx, key, value)?;
tx.commit()?; tx.commit()?;
Ok(()) Ok(())
} }
@ -212,7 +212,7 @@ impl<'a, 'db> LmdbTx<'a, 'db> {
impl<'a, 'db> ITx for LmdbTx<'a, 'db> { impl<'a, 'db> ITx for LmdbTx<'a, 'db> {
fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> { fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> {
let tree = self.get_tree(tree)?; let tree = self.get_tree(tree)?;
match tree.get(&self.tx, &key)? { match tree.get(&self.tx, key)? {
Some(v) => Ok(Some(v.to_vec())), Some(v) => Ok(Some(v.to_vec())),
None => Ok(None), None => Ok(None),
} }
@ -223,12 +223,12 @@ impl<'a, 'db> ITx for LmdbTx<'a, 'db> {
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> { fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
let tree = *self.get_tree(tree)?; let tree = *self.get_tree(tree)?;
tree.put(&mut self.tx, &key, &value)?; tree.put(&mut self.tx, key, value)?;
Ok(()) Ok(())
} }
fn remove(&mut self, tree: usize, key: &[u8]) -> Result<bool> { fn remove(&mut self, tree: usize, key: &[u8]) -> Result<bool> {
let tree = *self.get_tree(tree)?; let tree = *self.get_tree(tree)?;
let deleted = tree.delete(&mut self.tx, &key)?; let deleted = tree.delete(&mut self.tx, key)?;
Ok(deleted) Ok(deleted)
} }

View file

@ -29,8 +29,7 @@ async fn test_bucket_all() {
.unwrap() .unwrap()
.iter() .iter()
.filter(|x| x.name.as_ref().is_some()) .filter(|x| x.name.as_ref().is_some())
.find(|x| x.name.as_ref().unwrap() == "hello") .any(|x| x.name.as_ref().unwrap() == "hello"));
.is_some());
} }
{ {
// Get its location // Get its location
@ -75,13 +74,12 @@ async fn test_bucket_all() {
{ {
// Check bucket is deleted with List buckets // Check bucket is deleted with List buckets
let r = ctx.client.list_buckets().send().await.unwrap(); let r = ctx.client.list_buckets().send().await.unwrap();
assert!(r assert!(!r
.buckets .buckets
.as_ref() .as_ref()
.unwrap() .unwrap()
.iter() .iter()
.filter(|x| x.name.as_ref().is_some()) .filter(|x| x.name.as_ref().is_some())
.find(|x| x.name.as_ref().unwrap() == "hello") .any(|x| x.name.as_ref().unwrap() == "hello"));
.is_none());
} }
} }