From 25707da14af93fd7383cd721beae322abb13f36b Mon Sep 17 00:00:00 2001 From: ndungudedan Date: Wed, 26 Feb 2025 02:21:50 +0300 Subject: [PATCH] hashes: Remove Clone trait bound from Tag Implementors of the Tag trait had to use the #[derive(Clone)] attribute. This change eliminates this need by removing the Clone trait bound from the Tag trait. --- hashes/src/sha256t/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 core::hash::Hash for Hash { crate::internal_macros::hash_trait_impls!(256, false, T: Tag); /// Engine to compute SHA256t hash function. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct HashEngine(sha256::HashEngine, PhantomData); impl Default for HashEngine { @@ -128,6 +128,12 @@ impl Default for HashEngine { } } +impl Clone for HashEngine { + fn clone(&self) -> Self { + Self(self.0.clone(), PhantomData) + } +} + impl crate::HashEngine for HashEngine { const BLOCK_SIZE: usize = 64; // Same as sha256::HashEngine::BLOCK_SIZE; fn input(&mut self, data: &[u8]) { self.0.input(data) }