From 9ea7fc12c0489173847afb17cc771147da5980c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Glotfelty=20=F0=9F=9A=80?= Date: Mon, 27 Jul 2020 15:47:29 +0000 Subject: [PATCH] renamed variables --- strum_macros/src/macros/enum_messages.rs | 12 ++++++------ strum_macros/src/macros/enum_properties.rs | 6 +++--- strum_macros/src/macros/enum_variant_names.rs | 4 ++-- strum_macros/src/macros/strings/display.rs | 7 +++---- strum_macros/src/macros/strings/to_string.rs | 8 ++++---- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/strum_macros/src/macros/enum_messages.rs b/strum_macros/src/macros/enum_messages.rs index 8a45aba..bca25e8 100644 --- a/strum_macros/src/macros/enum_messages.rs +++ b/strum_macros/src/macros/enum_messages.rs @@ -11,16 +11,16 @@ pub fn enum_message_inner(ast: &syn::DeriveInput) -> TokenStream { _ => panic!("EnumMessage only works on Enums"), }; - let type_meta = ast.get_type_properties(); + let type_properties = ast.get_type_properties(); let mut arms = Vec::new(); let mut detailed_arms = Vec::new(); let mut serializations = Vec::new(); for variant in variants { - let meta = variant.get_variant_properties(); - let messages = meta.message.as_ref(); - let detailed_messages = meta.detailed_message.as_ref(); + let variant_properties = variant.get_variant_properties(); + let messages = variant_properties.message.as_ref(); + let detailed_messages = variant_properties.detailed_message.as_ref(); let ident = &variant.ident; use syn::Fields::*; @@ -32,7 +32,7 @@ pub fn enum_message_inner(ast: &syn::DeriveInput) -> TokenStream { // You can't disable getting the serializations. { - let serialization_variants = meta.get_serializations(type_meta.case_style); + let serialization_variants = variant_properties.get_serializations(type_properties.case_style); let count = serialization_variants.len(); serializations.push(quote! { @@ -44,7 +44,7 @@ pub fn enum_message_inner(ast: &syn::DeriveInput) -> TokenStream { } // But you can disable the messages. - if meta.is_disabled { + if variant_properties.is_disabled { continue; } diff --git a/strum_macros/src/macros/enum_properties.rs b/strum_macros/src/macros/enum_properties.rs index 7c34ccd..469aafa 100644 --- a/strum_macros/src/macros/enum_properties.rs +++ b/strum_macros/src/macros/enum_properties.rs @@ -14,12 +14,12 @@ pub fn enum_properties_inner(ast: &syn::DeriveInput) -> TokenStream { let mut arms = Vec::new(); for variant in variants { let ident = &variant.ident; - let meta = variant.get_variant_properties(); + let variant_properties = variant.get_variant_properties(); let mut string_arms = Vec::new(); let mut bool_arms = Vec::new(); let mut num_arms = Vec::new(); // But you can disable the messages. - if meta.is_disabled { + if variant_properties.is_disabled { continue; } @@ -30,7 +30,7 @@ pub fn enum_properties_inner(ast: &syn::DeriveInput) -> TokenStream { Named(..) => quote! { {..} }, }; - for (key, value) in meta.string_props { + for (key, value) in variant_properties.string_props { string_arms.push(quote! { #key => ::std::option::Option::Some( #value )}) } diff --git a/strum_macros/src/macros/enum_variant_names.rs b/strum_macros/src/macros/enum_variant_names.rs index 4da8e1e..588c418 100644 --- a/strum_macros/src/macros/enum_variant_names.rs +++ b/strum_macros/src/macros/enum_variant_names.rs @@ -14,11 +14,11 @@ pub fn enum_variant_names_inner(ast: &syn::DeriveInput) -> TokenStream { }; // Derives for the generated enum - let type_meta = ast.get_type_properties(); + let type_properties = ast.get_type_properties(); let names = variants .iter() - .map(|v| v.ident.convert_case(type_meta.case_style)) + .map(|v| v.ident.convert_case(type_properties.case_style)) .collect::>(); quote! { diff --git a/strum_macros/src/macros/strings/display.rs b/strum_macros/src/macros/strings/display.rs index 6abcd1e..20fe361 100644 --- a/strum_macros/src/macros/strings/display.rs +++ b/strum_macros/src/macros/strings/display.rs @@ -15,7 +15,6 @@ pub fn display_inner(ast: &syn::DeriveInput) -> TokenStream { let mut arms = Vec::new(); for variant in variants { - use syn::Fields::*; let ident = &variant.ident; let variant_properties = variant.get_variant_properties(); @@ -27,9 +26,9 @@ pub fn display_inner(ast: &syn::DeriveInput) -> TokenStream { let output = variant_properties.get_preferred_name(type_properties.case_style); let params = match variant.fields { - Unit => quote! {}, - Unnamed(..) => quote! { (..) }, - Named(..) => quote! { {..} }, + syn::Fields::Unit => quote! {}, + syn::Fields::Unnamed(..) => quote! { (..) }, + syn::Fields::Named(..) => quote! { {..} }, }; arms.push(quote! { #name::#ident #params => f.pad(#output) }); diff --git a/strum_macros/src/macros/strings/to_string.rs b/strum_macros/src/macros/strings/to_string.rs index a4caab8..234742f 100644 --- a/strum_macros/src/macros/strings/to_string.rs +++ b/strum_macros/src/macros/strings/to_string.rs @@ -11,19 +11,19 @@ pub fn to_string_inner(ast: &syn::DeriveInput) -> TokenStream { _ => panic!("ToString only works on Enums"), }; - let type_meta = ast.get_type_properties(); + let type_properties = ast.get_type_properties(); let mut arms = Vec::new(); for variant in variants { use syn::Fields::*; let ident = &variant.ident; - let meta = variant.get_variant_properties(); + let variant_properties = variant.get_variant_properties(); - if meta.is_disabled { + if variant_properties.is_disabled { continue; } // Look at all the serialize attributes. - let output = meta.get_preferred_name(type_meta.case_style); + let output = variant_properties.get_preferred_name(type_properties.case_style); let params = match variant.fields { Unit => quote! {},