diff --git a/grovedb/src/operations/insert/mod.rs b/grovedb/src/operations/insert/mod.rs index 6eb726ad..23582e3d 100644 --- a/grovedb/src/operations/insert/mod.rs +++ b/grovedb/src/operations/insert/mod.rs @@ -72,7 +72,7 @@ impl GroveDb { let tx = TxRef::new(&self.db, transaction); let mut cost = OperationCost::default(); - let merk_cache = MerkCache::new(&self, tx.as_ref(), grove_version); + let merk_cache = MerkCache::new(self, tx.as_ref(), grove_version); cost_return_on_error!( &mut cost, diff --git a/grovedb/src/reference_path.rs b/grovedb/src/reference_path.rs index a5e54f95..6af429c3 100644 --- a/grovedb/src/reference_path.rs +++ b/grovedb/src/reference_path.rs @@ -137,9 +137,9 @@ fn display_path(path: &[Vec]) -> String { .map(|bytes| { let mut hx = hex::encode(bytes); if let Ok(s) = String::from_utf8(bytes.clone()) { - hx.push_str("("); + hx.push('('); hx.push_str(&s); - hx.push_str(")"); + hx.push(')'); } hx diff --git a/grovedb/src/util.rs b/grovedb/src/util.rs index 321cd526..b6a1a267 100644 --- a/grovedb/src/util.rs +++ b/grovedb/src/util.rs @@ -44,7 +44,7 @@ impl<'a, 'db> TxRef<'a, 'db> { } } -impl<'a, 'db> AsRef> for TxRef<'a, 'db> { +impl<'db> AsRef> for TxRef<'_, 'db> { fn as_ref(&self) -> &Transaction<'db> { match self { TxRef::Owned(tx) => tx, diff --git a/merk/src/merk/meta.rs b/merk/src/merk/meta.rs index e967dfd2..a51b7acf 100644 --- a/merk/src/merk/meta.rs +++ b/merk/src/merk/meta.rs @@ -10,7 +10,7 @@ use crate::Error; impl<'db, S: StorageContext<'db>> Merk { /// Get metadata for the Merk under `key`. - pub fn get_meta<'s>(&'s mut self, key: Vec) -> CostResult, Error> { + pub fn get_meta(&mut self, key: Vec) -> CostResult, Error> { match self.meta_cache.entry(key) { Entry::Occupied(e) => Ok(e.into_mut().as_deref()).wrap_with_cost(Default::default()), Entry::Vacant(e) => self @@ -34,7 +34,7 @@ impl<'db, S: StorageContext<'db>> Merk { /// Delete metadata under `key`. pub fn delete_meta(&mut self, key: &[u8]) -> CostResult<(), Error> { self.storage - .delete_meta(&key, None) + .delete_meta(key, None) .map_ok(|_| { self.meta_cache.remove(key); }) diff --git a/merk/src/merk/mod.rs b/merk/src/merk/mod.rs index b5d9e01b..bc28f460 100644 --- a/merk/src/merk/mod.rs +++ b/merk/src/merk/mod.rs @@ -189,7 +189,7 @@ impl<'a, I: RawIterator> KVIterator<'a, I> { } // Cannot be an Iterator as it should return cost -impl<'a, I: RawIterator> KVIterator<'a, I> { +impl KVIterator<'_, I> { /// Next key-value pub fn next_kv(&mut self) -> CostContext, Vec)>> { let mut cost = OperationCost::default(); diff --git a/path/src/subtree_path.rs b/path/src/subtree_path.rs index b754b91e..48929a17 100644 --- a/path/src/subtree_path.rs +++ b/path/src/subtree_path.rs @@ -52,7 +52,7 @@ pub struct SubtreePath<'b, B> { pub(crate) ref_variant: SubtreePathInner<'b, B>, } -impl<'b, B: AsRef<[u8]>> Display for SubtreePath<'b, B> { +impl> Display for SubtreePath<'_, B> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let path = self.to_vec(); @@ -98,7 +98,7 @@ pub(crate) enum SubtreePathInner<'b, B> { SubtreePathIter(SubtreePathIter<'b, B>), } -impl<'bl, 'br, BL, BR> PartialEq> for SubtreePath<'bl, BL> +impl<'br, BL, BR> PartialEq> for SubtreePath<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -115,7 +115,7 @@ where /// can guarantee is to be free of false equality; however, seemingly unrelated /// subtrees can come one after another if they share the same length, which was /// (not) done for performance reasons. -impl<'bl, 'br, BL, BR> PartialOrd> for SubtreePath<'bl, BL> +impl<'br, BL, BR> PartialOrd> for SubtreePath<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -134,7 +134,7 @@ where } } -impl<'bl, 'br, BL, BR> PartialOrd> for SubtreePathBuilder<'bl, BL> +impl<'br, BL, BR> PartialOrd> for SubtreePathBuilder<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -153,7 +153,7 @@ where } } -impl<'bl, 'br, BL, BR> PartialOrd> for SubtreePath<'bl, BL> +impl<'br, BL, BR> PartialOrd> for SubtreePath<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -163,7 +163,7 @@ where } } -impl<'bl, BL> Ord for SubtreePath<'bl, BL> +impl Ord for SubtreePath<'_, BL> where BL: AsRef<[u8]>, { @@ -172,7 +172,7 @@ where } } -impl<'bl, BL> Ord for SubtreePathBuilder<'bl, BL> +impl Ord for SubtreePathBuilder<'_, BL> where BL: AsRef<[u8]>, { @@ -181,7 +181,7 @@ where } } -impl<'b, B: AsRef<[u8]>> Eq for SubtreePath<'b, B> {} +impl> Eq for SubtreePath<'_, B> {} impl<'b, B> From> for SubtreePath<'b, B> { fn from(ref_variant: SubtreePathInner<'b, B>) -> Self { @@ -211,7 +211,7 @@ impl<'s, 'b, B> From<&'s SubtreePathBuilder<'b, B>> for SubtreePath<'s, B> { /// Hash order is the same as iteration order: from most deep path segment up to /// root. -impl<'b, B: AsRef<[u8]>> Hash for SubtreePath<'b, B> { +impl> Hash for SubtreePath<'_, B> { fn hash(&self, state: &mut H) { match &self.ref_variant { SubtreePathInner::Slice(slice) => slice diff --git a/path/src/subtree_path_builder.rs b/path/src/subtree_path_builder.rs index f3a7d553..d834a5f3 100644 --- a/path/src/subtree_path_builder.rs +++ b/path/src/subtree_path_builder.rs @@ -46,7 +46,7 @@ pub struct SubtreePathBuilder<'b, B> { pub(crate) relative: SubtreePathRelative<'b>, } -impl<'b, B> Clone for SubtreePathBuilder<'b, B> { +impl Clone for SubtreePathBuilder<'_, B> { fn clone(&self) -> Self { SubtreePathBuilder { base: self.base.clone(), @@ -57,14 +57,14 @@ impl<'b, B> Clone for SubtreePathBuilder<'b, B> { /// Hash order is the same as iteration order: from most deep path segment up to /// root. -impl<'b, B: AsRef<[u8]>> Hash for SubtreePathBuilder<'b, B> { +impl> Hash for SubtreePathBuilder<'_, B> { fn hash(&self, state: &mut H) { self.relative.hash(state); self.base.hash(state); } } -impl<'bl, 'br, BL, BR> PartialEq> for SubtreePathBuilder<'bl, BL> +impl<'br, BL, BR> PartialEq> for SubtreePathBuilder<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -74,7 +74,7 @@ where } } -impl<'bl, 'br, BL, BR> PartialEq> for SubtreePath<'bl, BL> +impl<'br, BL, BR> PartialEq> for SubtreePath<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -84,7 +84,7 @@ where } } -impl<'bl, 'br, BL, BR> PartialEq> for SubtreePathBuilder<'bl, BL> +impl<'br, BL, BR> PartialEq> for SubtreePathBuilder<'_, BL> where BL: AsRef<[u8]>, BR: AsRef<[u8]>, @@ -94,7 +94,7 @@ where } } -impl<'b, B: AsRef<[u8]>> Eq for SubtreePathBuilder<'b, B> {} +impl> Eq for SubtreePathBuilder<'_, B> {} impl<'s, 'b, B> From<&'s SubtreePath<'b, B>> for SubtreePathBuilder<'b, B> { fn from(value: &'s SubtreePath<'b, B>) -> Self { @@ -158,7 +158,7 @@ impl Default for SubtreePathBuilder<'static, [u8; 0]> { } } -impl<'b, B> SubtreePathBuilder<'b, B> { +impl SubtreePathBuilder<'_, B> { /// Makes an owned `SubtreePathBuilder` out of iterator. pub fn owned_from_iter>(iter: impl IntoIterator) -> Self { let bytes = iter.into_iter().fold(CompactBytes::new(), |mut bytes, s| { @@ -175,7 +175,7 @@ impl<'b, B> SubtreePathBuilder<'b, B> { } /// Create an owned version of `SubtreePathBuilder` from `SubtreePath`. - pub fn owned_from_path<'a, S: AsRef<[u8]>>(path: SubtreePath<'a, S>) -> Self { + pub fn owned_from_path>(path: SubtreePath) -> Self { Self::owned_from_iter(path.to_vec()) } } @@ -240,9 +240,10 @@ impl<'b, B: AsRef<[u8]>> SubtreePathBuilder<'b, B> { } } - /// Get a derived path for a parent and a chopped segment. The lifetime of returned path is - /// constrained solely by the original slice that this whole path hierarchy is based upon, and the point - /// of derivation has no effect on it. + /// Get a derived path for a parent and a chopped segment. The lifetime of + /// returned path is constrained solely by the original slice that this + /// whole path hierarchy is based upon, and the point of derivation has + /// no effect on it. pub fn derive_parent_owned(&self) -> Option<(SubtreePathBuilder<'b, B>, Vec)> { match &self.relative { SubtreePathRelative::Empty => self diff --git a/storage/src/storage.rs b/storage/src/storage.rs index 3a0b5485..7b3a9bb6 100644 --- a/storage/src/storage.rs +++ b/storage/src/storage.rs @@ -305,6 +305,7 @@ impl StorageBatch { } } + #[cfg(test)] /// Returns a number of operations in the batch. pub fn len(&self) -> usize { let operations = self.operations.borrow();