hashes: remove private `internal_new` method
This method is used to implement `from_byte_array`. But there is no need for the method to exist. We can just inline it in `from_byte_array` and reduce the amount of indirection in our macros. Also make the same change in sha256t.
This commit is contained in:
parent
0aeff359f5
commit
a5d96ceb39
|
@ -130,12 +130,8 @@ macro_rules! hash_type_no_default {
|
|||
}
|
||||
|
||||
impl Hash {
|
||||
const fn internal_new(arr: [u8; $bits / 8]) -> Self { Hash(arr) }
|
||||
|
||||
/// Constructs a new hash from the underlying byte array.
|
||||
pub const fn from_byte_array(bytes: [u8; $bits / 8]) -> Self {
|
||||
Self::internal_new(bytes)
|
||||
}
|
||||
pub const fn from_byte_array(bytes: [u8; $bits / 8]) -> Self { Hash(bytes) }
|
||||
|
||||
/// Copies a byte slice into a hash object.
|
||||
#[deprecated(since = "0.15.0", note = "use `from_byte_array` instead")]
|
||||
|
@ -151,7 +147,7 @@ macro_rules! hash_type_no_default {
|
|||
} else {
|
||||
let mut ret = [0; $bits / 8];
|
||||
ret.copy_from_slice(sl);
|
||||
Ok(Self::internal_new(ret))
|
||||
Ok(Self::from_byte_array(ret))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,8 @@ impl<T> Hash<T>
|
|||
where
|
||||
T: Tag,
|
||||
{
|
||||
const fn internal_new(arr: [u8; 32]) -> Self { Hash(PhantomData, arr) }
|
||||
|
||||
/// Constructs a new hash from the underlying byte array.
|
||||
pub const fn from_byte_array(bytes: [u8; 32]) -> Self { Self::internal_new(bytes) }
|
||||
pub const fn from_byte_array(bytes: [u8; 32]) -> Self { Self(PhantomData, bytes) }
|
||||
|
||||
/// Copies a byte slice into a hash object.
|
||||
#[deprecated(since = "0.15.0", note = "use `from_byte_array` instead")]
|
||||
|
|
Loading…
Reference in New Issue