From 6d18bf3a52c9fc687c02ecfe9e5c5e229c1ba21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=A1=E5=94=AF=E5=AE=87?= Date: Thu, 23 Oct 2025 17:00:07 +0800 Subject: [PATCH 1/2] lift clone constraint on H --- src/hyperloglog.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/hyperloglog.rs b/src/hyperloglog.rs index 6bda970..a676cc0 100644 --- a/src/hyperloglog.rs +++ b/src/hyperloglog.rs @@ -41,7 +41,7 @@ use crate::HyperLogLogError; /// algorithm", Philippe Flajolet, Éric Fusy, Olivier Gandouet and Frédéric /// Meunier.](http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf) /// -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct HyperLogLogPF where H: Hash + ?Sized, @@ -54,6 +54,22 @@ where phantom: PhantomData, } +impl Clone for HyperLogLogPF +where + H: Hash + ?Sized, + B: BuildHasher + Clone, +{ + fn clone(&self) -> Self { + Self { + builder: self.builder.clone(), + count: self.count, + precision: self.precision, + registers: self.registers.clone(), + phantom: self.phantom, + } + } +} + impl HyperLogLogPF where H: Hash + ?Sized, From 03f8aac10b7bd5d5709afd8d87ccd992f1283d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=A1=E5=94=AF=E5=AE=87?= Date: Thu, 23 Oct 2025 17:04:17 +0800 Subject: [PATCH 2/2] also for HLL+ --- src/hyperloglogplus.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hyperloglogplus.rs b/src/hyperloglogplus.rs index 9264ced..f06dc0d 100644 --- a/src/hyperloglogplus.rs +++ b/src/hyperloglogplus.rs @@ -53,7 +53,7 @@ use crate::HyperLogLogError; /// of the Art Cardinality Estimation Algorithm", Stefan Heule, Marc /// Nunkesser and Alexander Hall.](https://goo.gl/iU8Ig) /// -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct HyperLogLogPlus where H: Hash + ?Sized, @@ -68,6 +68,24 @@ where phantom: PhantomData, } +impl Clone for HyperLogLogPlus +where + H: Hash + ?Sized, + B: BuildHasher + Clone, +{ + fn clone(&self) -> Self { + Self { + builder: self.builder.clone(), + precision: self.precision, + counts: self.counts, + tmpset: self.tmpset.clone(), + sparse: self.sparse.clone(), + registers: self.registers.clone(), + phantom: self.phantom, + } + } +} + impl HyperLogLogPlus where H: Hash + ?Sized,