From 2749b442daa7d96f879c98df55b64089956e6fce Mon Sep 17 00:00:00 2001 From: Evgeny Fomin Date: Fri, 27 Dec 2024 18:48:51 +0100 Subject: [PATCH] address complex type clippy warning in merk cache --- grovedb/src/merk_cache.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grovedb/src/merk_cache.rs b/grovedb/src/merk_cache.rs index 993a9591..c6a41e64 100644 --- a/grovedb/src/merk_cache.rs +++ b/grovedb/src/merk_cache.rs @@ -15,13 +15,17 @@ use crate::{Error, GroveDb, Transaction}; type TxMerk<'db> = Merk>; +/// We store Merk on heap to preserve its location as well as borrow flag +/// alongside. +type CachedMerkEntry<'db> = Box<(Cell, TxMerk<'db>)>; + /// Structure to keep subtrees open in memory for repeated access. pub(crate) struct MerkCache<'db, 'b, B: AsRef<[u8]>> { db: &'db GroveDb, pub(crate) version: &'db GroveVersion, batch: Box, tx: &'db Transaction<'db>, - merks: UnsafeCell, Box<(Cell, TxMerk<'db>)>>>, + merks: UnsafeCell, CachedMerkEntry<'db>>>, } impl<'db, 'b, B: AsRef<[u8]>> MerkCache<'db, 'b, B> { @@ -171,7 +175,7 @@ pub(crate) struct MerkHandle<'db, 'c> { taken_handle: &'c Cell, } -impl<'db, 'c> MerkHandle<'db, 'c> { +impl<'db> MerkHandle<'db, '_> { pub(crate) fn for_merk(&mut self, f: impl FnOnce(&mut TxMerk<'db>) -> T) -> T { if self.taken_handle.get() { panic!("Attempt to have double &mut borrow on Merk");