Skip to content

Commit

Permalink
Use UFCS in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
liamaharon committed Sep 14, 2024
1 parent 7360c3c commit 25d906d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions bitcoin/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ macro_rules! impl_consensus_encoding {
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(
r: &mut R,
) -> core::result::Result<$thing, $crate::consensus::encode::Error> {
use internals::ToU64 as _;

let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE.to_u64());
let mut r = r.take(internals::ToU64::to_u64($crate::consensus::encode::MAX_VEC_SIZE));
Ok($thing {
$($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
})
Expand Down
8 changes: 2 additions & 6 deletions hashes/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ macro_rules! arr_newtype_fmt_impl {
impl<$($gen: $gent),*> $crate::_export::_core::fmt::LowerHex for $ty<$($gen),*> {
#[inline]
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
#[allow(unused)]
use crate::Hash as _;
let case = $crate::hex::Case::Lower;
if <$ty<$($gen),*>>::DISPLAY_BACKWARD {
if <$ty<$($gen),*> as crate::Hash>::DISPLAY_BACKWARD {
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter().rev(), case)
} else {
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
Expand All @@ -21,10 +19,8 @@ macro_rules! arr_newtype_fmt_impl {
impl<$($gen: $gent),*> $crate::_export::_core::fmt::UpperHex for $ty<$($gen),*> {
#[inline]
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
#[allow(unused)]
use crate::Hash as _;
let case = $crate::hex::Case::Upper;
if <$ty<$($gen),*>>::DISPLAY_BACKWARD {
if <$ty<$($gen),*> as crate::Hash>::DISPLAY_BACKWARD {
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter().rev(), case)
} else {
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
Expand Down
4 changes: 1 addition & 3 deletions hashes/src/serde_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ macro_rules! serde_impl(
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {
const N : usize = $len;
fn from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, $crate::FromSliceError> {
#[allow(unused_imports)]
use $crate::Hash as _;
$t::from_slice(sl)
<$t<$($gen),*> as $crate::Hash>::from_slice(sl)
}
}

Expand Down

0 comments on commit 25d906d

Please sign in to comment.