Skip to content

Commit

Permalink
Run cargo fmt (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
paholg authored Feb 13, 2023
1 parent 2859c13 commit d5ab521
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ fn variant_to_unary_pat(variant: &Variant) -> TokenStream2 {

match &variant.fields {
syn::Fields::Named(named) => {
let vars: Punctuated<Ident, Token![,]> =
named.named.iter().map(snake_case).collect();
let vars: Punctuated<Ident, Token![,]> = named.named.iter().map(snake_case).collect();
quote!(#ident{#vars})
}
syn::Fields::Unnamed(unnamed) => {
let vars: Punctuated<Ident, Token![,]> = unnamed
.unnamed
.iter()
.map(snake_case)
.collect();
let vars: Punctuated<Ident, Token![,]> =
unnamed.unnamed.iter().map(snake_case).collect();
quote!(#ident(#vars))
}
syn::Fields::Unit => quote!(#ident),
Expand All @@ -77,8 +73,7 @@ fn partial_eq_arm(variant: &Variant, child_ident: &Ident, parent_ident: &Ident)

match &variant.fields {
syn::Fields::Named(named) => {
let vars1: Punctuated<Ident, Token![,]> =
named.named.iter().map(snake_case).collect();
let vars1: Punctuated<Ident, Token![,]> = named.named.iter().map(snake_case).collect();
let vars2: Punctuated<Ident, Token![,]> =
vars1.iter().map(|v| format_ident!("{}2", v)).collect();
let vars_rhs: Punctuated<TokenStream2, Token![&&]> = vars1
Expand All @@ -96,11 +91,8 @@ fn partial_eq_arm(variant: &Variant, child_ident: &Ident, parent_ident: &Ident)
quote!((#child_ident::#ident{#vars1}, #parent_ident::#ident{#vars2}) => #vars_rhs)
}
syn::Fields::Unnamed(unnamed) => {
let vars1: Punctuated<Ident, Token![,]> = unnamed
.unnamed
.iter()
.map(snake_case)
.collect();
let vars1: Punctuated<Ident, Token![,]> =
unnamed.unnamed.iter().map(snake_case).collect();
let vars2: Punctuated<Ident, Token![,]> =
vars1.iter().map(|v| format_ident!("{}2", v)).collect();
let vars_rhs: Punctuated<TokenStream2, Token![&&]> = vars1
Expand Down Expand Up @@ -305,10 +297,7 @@ pub fn subenum(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
}
}

let enums: Vec<_> = enums
.into_values()
.map(|e| e.build(&input, data))
.collect();
let enums: Vec<_> = enums.into_values().map(|e| e.build(&input, data)).collect();

sanitize_input(&mut input);

Expand Down

0 comments on commit d5ab521

Please sign in to comment.