Skip to content

Commit

Permalink
Cleaner match for the Data::Private cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 24, 2020
1 parent a8cf6ee commit 06457c8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions build.rs
Expand Up @@ -38,31 +38,27 @@ fn node_tokens(node: &Node, tokens: &mut TokenStream) {
let ident = format_ident!("{}", node.ident);

let data = match &node.data {
Data::Private => {
if ident == "LitStr"
|| ident == "LitByteStr"
|| ident == "LitByte"
|| ident == "LitChar"
{
Data::Private => match node.ident.as_str() {
"LitStr" | "LitByteStr" | "LitByte" | "LitChar" => {
quote! {
js!(#ident {
value: self.value(),
suffix: self.suffix(),
span: self.span()
})
}
} else if ident == "LitInt" || ident == "LitFloat" {
}
"LitInt" | "LitFloat" => {
quote! {
js!(#ident {
digits: self.base10_digits(),
suffix: self.suffix(),
span: self.span()
})
}
} else {
unreachable!()
}
}
_ => unreachable!(),
},
Data::Struct(fields) => {
let mut fields = fields.iter().collect::<Vec<_>>();

Expand Down

0 comments on commit 06457c8

Please sign in to comment.