Merge rust-bitcoin/rust-bitcoin#3359: Use UFCS in macros
25d906d936
Use UFCS in macros (Liam Aharon) Pull request description: Closes #3304 ACKs for top commit: apoelstra: ACK25d906d936
successfully ran local tests tcharding: ACK25d906d936
Tree-SHA512: a02a8507bcec73dab1ec8d49e45eab327d989c276d931520e0fff312faf7d3165292c300fb9414314f9b94b1255ee49a0fb64303df6d971c9089226b6873c36a
This commit is contained in:
commit
a543b45df1
|
@ -33,9 +33,7 @@ macro_rules! impl_consensus_encoding {
|
||||||
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(
|
fn consensus_decode<R: $crate::io::BufRead + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> core::result::Result<$thing, $crate::consensus::encode::Error> {
|
) -> core::result::Result<$thing, $crate::consensus::encode::Error> {
|
||||||
use internals::ToU64 as _;
|
let mut r = r.take(internals::ToU64::to_u64($crate::consensus::encode::MAX_VEC_SIZE));
|
||||||
|
|
||||||
let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE.to_u64());
|
|
||||||
Ok($thing {
|
Ok($thing {
|
||||||
$($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
|
$($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,10 +7,8 @@ macro_rules! arr_newtype_fmt_impl {
|
||||||
impl<$($gen: $gent),*> $crate::_export::_core::fmt::LowerHex for $ty<$($gen),*> {
|
impl<$($gen: $gent),*> $crate::_export::_core::fmt::LowerHex for $ty<$($gen),*> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
|
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;
|
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)
|
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter().rev(), case)
|
||||||
} else {
|
} else {
|
||||||
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
|
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
|
||||||
|
@ -21,10 +19,8 @@ macro_rules! arr_newtype_fmt_impl {
|
||||||
impl<$($gen: $gent),*> $crate::_export::_core::fmt::UpperHex for $ty<$($gen),*> {
|
impl<$($gen: $gent),*> $crate::_export::_core::fmt::UpperHex for $ty<$($gen),*> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
|
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;
|
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)
|
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter().rev(), case)
|
||||||
} else {
|
} else {
|
||||||
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
|
$crate::hex::fmt_hex_exact!(f, $bytes, self.0.iter(), case)
|
||||||
|
|
|
@ -112,9 +112,7 @@ macro_rules! serde_impl(
|
||||||
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {
|
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {
|
||||||
const N : usize = $len;
|
const N : usize = $len;
|
||||||
fn from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, $crate::FromSliceError> {
|
fn from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, $crate::FromSliceError> {
|
||||||
#[allow(unused_imports)]
|
<$t<$($gen),*> as $crate::Hash>::from_slice(sl)
|
||||||
use $crate::Hash as _;
|
|
||||||
$t::from_slice(sl)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue