Skip to content

Commit

Permalink
Improve variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Jul 8, 2024
1 parent 3f91533 commit 7d375a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libshvproto-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub fn derive_from_rpcvalue(item: TokenStream) -> TokenStream {
let identifier = field.ident.as_ref().unwrap();
let field_name = field
.attrs.first()
.and_then(|x| x.meta.require_name_value().ok())
.filter(|x| x.path.is_ident("field_name"))
.map(|x| if let syn::Expr::Lit(expr) = &x.value { expr } else { panic!("Expected a string literal for 'field_name'") })
.map(|x| if let syn::Lit::Str(expr) = &x.lit { expr.value() } else { panic!("Expected a string literal for 'field_name'") })
.and_then(|attr| attr.meta.require_name_value().ok())
.filter(|meta_name_value| meta_name_value.path.is_ident("field_name"))
.map(|meta_name_value| if let syn::Expr::Lit(expr) = &meta_name_value.value { expr } else { panic!("Expected a string literal for 'field_name'") })
.map(|literal| if let syn::Lit::Str(expr) = &literal.lit { expr.value() } else { panic!("Expected a string literal for 'field_name'") })
.unwrap_or_else(|| identifier.to_string().to_case(Case::Camel));

struct_initializers.extend(quote!{
Expand Down

0 comments on commit 7d375a6

Please sign in to comment.