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.
This commit is contained in:
parent
e80ce4a89c
commit
25707da14a
|
@ -10,7 +10,7 @@ use crate::sha256::Midstate;
|
||||||
use crate::{sha256, HashEngine as _};
|
use crate::{sha256, HashEngine as _};
|
||||||
|
|
||||||
/// Trait representing a tag that can be used as a context for SHA256t hashes.
|
/// 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.
|
/// The [`Midstate`] after pre-tagging the hash engine.
|
||||||
const MIDSTATE: sha256::Midstate;
|
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);
|
crate::internal_macros::hash_trait_impls!(256, false, T: Tag);
|
||||||
|
|
||||||
/// Engine to compute SHA256t hash function.
|
/// Engine to compute SHA256t hash function.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug)]
|
||||||
pub struct HashEngine<T>(sha256::HashEngine, PhantomData<T>);
|
pub struct HashEngine<T>(sha256::HashEngine, PhantomData<T>);
|
||||||
|
|
||||||
impl<T: Tag> Default for HashEngine<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> {
|
impl<T: Tag> crate::HashEngine for HashEngine<T> {
|
||||||
const BLOCK_SIZE: usize = 64; // Same as sha256::HashEngine::BLOCK_SIZE;
|
const BLOCK_SIZE: usize = 64; // Same as sha256::HashEngine::BLOCK_SIZE;
|
||||||
fn input(&mut self, data: &[u8]) { self.0.input(data) }
|
fn input(&mut self, data: &[u8]) { self.0.input(data) }
|
||||||
|
|
Loading…
Reference in New Issue