Stop using `$len` in `hash_newtype`

We want to get rid of this argument since its value is implied by the
inner hash type. First we stop using it.
This commit is contained in:
Martin Habovstiak 2023-02-22 01:09:01 +01:00
parent 483605add2
commit 752817e20d
1 changed files with 4 additions and 4 deletions

View File

@ -122,7 +122,7 @@ macro_rules! hash_newtype {
pub struct $newtype($hash);
$crate::hex_fmt_impl!($reverse, $newtype);
$crate::serde_impl!($newtype, $len);
$crate::serde_impl!($newtype, <$newtype as $crate::Hash>::LEN);
$crate::borrow_slice_impl!($newtype);
impl $newtype {
@ -208,9 +208,9 @@ macro_rules! hash_newtype {
}
}
impl $crate::_export::_core::convert::AsRef<[u8; $len]> for $newtype {
fn as_ref(&self) -> &[u8; $len] {
AsRef::<[u8; $len]>::as_ref(&self.0)
impl $crate::_export::_core::convert::AsRef<[u8; <$hash as $crate::Hash>::LEN]> for $newtype {
fn as_ref(&self) -> &[u8; <$hash as $crate::Hash>::LEN] {
AsRef::<[u8; <$hash as $crate::Hash>::LEN]>::as_ref(&self.0)
}
}