Use more descriptive names in serialization impl macros

This commit is contained in:
Matt Corallo 2021-03-24 14:31:03 -04:00
parent 25b9fd8079
commit ee0ffe5dfd

View file

@ -145,11 +145,11 @@ macro_rules! impl_writeable {
}
}
macro_rules! impl_writeable_len_match {
($st:ident, $cmp: tt, {$({$m: pat, $l: expr}),*}, {$($field:ident),*}) => {
impl Writeable for $st {
($struct: ident, $cmp: tt, {$({$match: pat, $length: expr}),*}, {$($field:ident),*}) => {
impl Writeable for $struct {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
let len = match *self {
$($m => $l,)*
$($match => $length,)*
};
w.size_hint(len);
#[cfg(any(test, feature = "fuzztarget"))]
@ -165,7 +165,7 @@ macro_rules! impl_writeable_len_match {
}
}
impl ::util::ser::Readable for $st {
impl ::util::ser::Readable for $struct {
fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, DecodeError> {
Ok(Self {
$($field: Readable::read(r)?),*
@ -173,8 +173,8 @@ macro_rules! impl_writeable_len_match {
}
}
};
($st:ident, {$({$m: pat, $l: expr}),*}, {$($field:ident),*}) => {
impl_writeable_len_match!($st, ==, { $({ $m, $l }),* }, { $($field),* });
($struct: ident, {$({$match: pat, $length: expr}),*}, {$($field:ident),*}) => {
impl_writeable_len_match!($struct, ==, { $({ $match, $length }),* }, { $($field),* });
}
}