chore: Slight attribute parsing cleanup
This commit is contained in:
@@ -6,7 +6,7 @@ use convert_case::{Case, Casing};
|
||||
use itertools::Itertools;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{ToTokens, quote};
|
||||
use syn::{DataEnum, DataStruct, DeriveInput, LitStr, Token, parse_macro_input, spanned::Spanned};
|
||||
use syn::{DataEnum, DataStruct, DeriveInput, LitStr, parse_macro_input, spanned::Spanned};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct StructField {
|
||||
@@ -294,10 +294,6 @@ fn parse_fields(
|
||||
as_name = value.parse()?;
|
||||
} else if meta.path.is_ident("default") {
|
||||
default = true;
|
||||
if meta.input.peek(Token![=]) {
|
||||
meta.input.parse::<Token![=]>()?;
|
||||
meta.input.parse::<LitStr>()?;
|
||||
}
|
||||
} else if meta.path.is_ident("flatten") {
|
||||
flatten = true;
|
||||
} else {
|
||||
@@ -366,8 +362,8 @@ fn typed_inner(ast: DeriveInput) -> syn::Result<TokenStream2> {
|
||||
)),
|
||||
}?);
|
||||
} else if meta.path.is_ident("tag") {
|
||||
meta.input.parse::<Token![=]>()?;
|
||||
tag = Some(meta.input.parse::<LitStr>()?);
|
||||
let value = meta.value()?;
|
||||
tag = Some(value.parse::<LitStr>()?);
|
||||
} else {
|
||||
return Err(syn::Error::new(meta.path.span(), "Unknown attribute"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user