Repository: rust-bitcoin/rust-bitcoin (language: rust)

Issue:
hashes: Remove `Clone` trait bound from `Tag`
If #4010 merges consider removing the `Clone` trait bound off of the `Tag` trait.

suggested here: https://github.com/rust-bitcoin/rust-bitcoin/pull/4010#discussion_r1942359979


Discussion / hints:

Fix patch:
diff --git a/hashes/src/sha256t/mod.rs b/hashes/src/sha256t/mod.rs
index 56592820e..22f835412 100644
--- a/hashes/src/sha256t/mod.rs
+++ b/hashes/src/sha256t/mod.rs
@@ -10,7 +10,7 @@ use crate::sha256::Midstate;
 use crate::{sha256, HashEngine as _};
 
 /// Trait representing a tag that can be used as a context for SHA256t hashes.
-pub trait Tag: Clone {
+pub trait Tag {
     /// The [`Midstate`] after pre-tagging the hash engine.
     const MIDSTATE: sha256::Midstate;
 }
@@ -118,7 +118,7 @@ impl<T: Tag> core::hash::Hash for Hash<T> {
 crate::internal_macros::hash_trait_impls!(256, false, T: Tag);
 
 /// Engine to compute SHA256t hash function.
-#[derive(Debug, Clone)]
+#[derive(Debug)]
 pub struct HashEngine<T>(sha256::HashEngine, PhantomData<T>);
 
 impl<T: Tag> Default for HashEngine<T> {
@@ -128,6 +128,12 @@ impl<T: Tag> Default for HashEngine<T> {
     }
 }
 
+impl<T: Tag> Clone for HashEngine<T> {
+    fn clone(&self) -> Self {
+        Self(self.0.clone(), PhantomData)
+    }
+}
+
 impl<T: Tag> crate::HashEngine for HashEngine<T> {
     const BLOCK_SIZE: usize = 64; // Same as sha256::HashEngine::BLOCK_SIZE;
     fn input(&mut self, data: &[u8]) { self.0.input(data) }


Test patch: