From 0ec91129d03f127284b1c1edbfefbf62112bc4e0 Mon Sep 17 00:00:00 2001 From: owainc <72195676+owainc@users.noreply.github.com> Date: Wed, 22 Oct 2025 16:54:27 +0100 Subject: [PATCH] Manually implement Clone trait for Pool struct Manually implement Clone to avoid unnecessary DB: Clone bound from derive macro. --- src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ee99dbc..a2d9b21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,7 @@ impl PoolBuilder { /// An asynchronous pool of SQLx database connections with tracing instrumentation. /// /// Wraps a SQLx [`Pool`] and propagates tracing attributes to all acquired connections. -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct Pool where DB: sqlx::Database, @@ -119,6 +119,18 @@ where attributes: Arc, } +impl Clone for Pool +where + DB: sqlx::Database, +{ + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + attributes: self.attributes.clone(), + } + } +} + impl From> for Pool where DB: sqlx::Database,