From 20bdf9831a60e7c1fdf9bd8f9c5843df649bdefb Mon Sep 17 00:00:00 2001 From: kralverde Date: Tue, 1 Jul 2025 21:21:19 -1000 Subject: [PATCH] clone all hashers --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8fe7be4..aeaa9ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,13 +193,17 @@ pub struct LruCache { tail: *mut LruEntry, } -impl Clone for LruCache +impl Clone for LruCache where K: Hash + PartialEq + Eq + Clone, V: Clone, + S: BuildHasher + Clone, { fn clone(&self) -> Self { - let mut new_lru = LruCache::new(self.cap()); + let mut new_lru = LruCache::construct( + self.cap(), + HashMap::with_capacity_and_hasher(self.cap().get(), self.map.hasher().clone()), + ); for (key, value) in self.iter().rev() { new_lru.push(key.clone(), value.clone());