inline constants in generated enum Encode impls
This commit is contained in:
parent
0355358e6c
commit
e3d2016a22
1 changed files with 2 additions and 7 deletions
|
|
@ -58,16 +58,11 @@ macro_rules! rpc_encode_decode {
|
|||
fn encode(self, w: &mut Writer, s: &mut S) {
|
||||
// HACK(eddyb): `Tag` enum duplicated between the
|
||||
// two impls as there's no other place to stash it.
|
||||
#[allow(non_upper_case_globals)]
|
||||
mod tag {
|
||||
#[repr(u8)] enum Tag { $($variant),* }
|
||||
|
||||
$(pub(crate) const $variant: u8 = Tag::$variant as u8;)*
|
||||
}
|
||||
#[repr(u8)] enum Tag { $($variant),* }
|
||||
|
||||
match self {
|
||||
$($name::$variant $(($field))* => {
|
||||
tag::$variant.encode(w, s);
|
||||
(Tag::$variant as u8).encode(w, s);
|
||||
$($field.encode(w, s);)*
|
||||
})*
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue