diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index 5bf196161..bf0157d82 100644 --- a/hashes/src/internal_macros.rs +++ b/hashes/src/internal_macros.rs @@ -186,13 +186,7 @@ macro_rules! hash_type { /// Hashes some bytes. #[allow(clippy::self_named_constructors)] // Hash is a noun and a verb. - pub fn hash(data: &[u8]) -> Self { - use $crate::HashEngine; - - let mut engine = Self::engine(); - engine.input(data); - Self::from_engine(engine) - } + pub fn hash(data: &[u8]) -> Self { ::hash(data) } /// Hashes all the byte slices retrieved from the iterator together. pub fn hash_byte_chunks(byte_slices: I) -> Self @@ -200,13 +194,7 @@ macro_rules! hash_type { B: AsRef<[u8]>, I: IntoIterator, { - use $crate::HashEngine; - - let mut engine = Self::engine(); - for slice in byte_slices { - engine.input(slice.as_ref()); - } - Self::from_engine(engine) + ::hash_byte_chunks(byte_slices) } diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 411897cba..61c769de2 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -227,11 +227,7 @@ macro_rules! sha256t_hash_newtype { /// Hashes some bytes. #[allow(unused)] // the user of macro may not need this pub fn hash(data: &[u8]) -> Self { - use $crate::HashEngine; - - let mut engine = Self::engine(); - engine.input(data); - Self::from_engine(engine) + <$hash_name as $crate::GeneralHash>::hash(data) } /// Hashes all the byte slices retrieved from the iterator together. @@ -241,13 +237,7 @@ macro_rules! sha256t_hash_newtype { B: AsRef<[u8]>, I: IntoIterator, { - use $crate::HashEngine; - - let mut engine = Self::engine(); - for slice in byte_slices { - engine.input(slice.as_ref()); - } - Self::from_engine(engine) + <$hash_name as $crate::GeneralHash>::hash_byte_chunks(byte_slices) } /// Hashes the entire contents of the `reader`.