mirror of https://codeberg.org/topola/topola.git
style(specctra_derive): run cargo fmt over it also
This commit is contained in:
parent
eca42160f0
commit
36628d04ae
|
|
@ -1,6 +1,6 @@
|
|||
use proc_macro::TokenStream;
|
||||
use syn::{Attribute, DeriveInput, LitStr, Meta, Token};
|
||||
use syn::punctuated::Punctuated;
|
||||
use syn::{Attribute, DeriveInput, LitStr, Meta, Token};
|
||||
|
||||
mod read;
|
||||
mod write;
|
||||
|
|
@ -33,18 +33,16 @@ fn parse_attributes(attrs: &Vec<Attribute>) -> FieldType {
|
|||
} else if path.is_ident("anon_vec") {
|
||||
return FieldType::AnonymousVec;
|
||||
}
|
||||
},
|
||||
}
|
||||
Meta::List(list) if list.path.is_ident("vec") => {
|
||||
return FieldType::NamedVec(list
|
||||
.parse_args_with(
|
||||
Punctuated::<LitStr, Token![,]>::parse_terminated
|
||||
)
|
||||
return FieldType::NamedVec(
|
||||
list.parse_args_with(Punctuated::<LitStr, Token![,]>::parse_terminated)
|
||||
.expect("#[vec(...)] must contain a list of string literals")
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect()
|
||||
.collect(),
|
||||
);
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,17 +53,17 @@ fn impl_field(field: &Field) -> TokenStream {
|
|||
quote! {
|
||||
#name: tokenizer.read_value()?,
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::AnonymousVec => {
|
||||
quote! {
|
||||
#name: tokenizer.read_array()?,
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::NamedVec(valid_aliases) => {
|
||||
quote! {
|
||||
#name: tokenizer.read_array_with_alias(&[#(#valid_aliases),*])?,
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::NotSpecified => {
|
||||
if let Path(type_path) = &field.ty {
|
||||
let segments = &type_path.path.segments;
|
||||
|
|
|
|||
|
|
@ -51,18 +51,18 @@ fn impl_field(field: &Field) -> TokenStream {
|
|||
quote! {
|
||||
writer.write_value(&self.#name)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::AnonymousVec => {
|
||||
quote! {
|
||||
writer.write_array(&self.#name)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::NamedVec(valid_aliases) => {
|
||||
let canonical_name = &valid_aliases[0];
|
||||
quote! {
|
||||
writer.write_named_array(#canonical_name, &self.#name)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
FieldType::NotSpecified => {
|
||||
if let Path(type_path) = &field.ty {
|
||||
let segments = &type_path.path.segments;
|
||||
|
|
|
|||
Loading…
Reference in New Issue