Format components dom_struct, domobject_derive and embedder_traits #21373

This commit is contained in:
kingdido999 2018-09-03 08:19:25 +08:00
parent aa61200eca
commit d76ddabba4
4 changed files with 47 additions and 19 deletions

View file

@ -25,7 +25,6 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
// Work around https://github.com/rust-lang/rust/issues/46489
let attributes: TokenStream = attributes.to_string().parse().unwrap();
let output: TokenStream = attributes.into_iter().chain(input.into_iter()).collect();
let item: Item = syn::parse(output).unwrap();
@ -36,7 +35,11 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
return quote!(#s2).into();
}
if let Fields::Named(ref f) = s.fields {
let f = f.named.first().expect("Must have at least one field").into_value();
let f = f
.named
.first()
.expect("Must have at least one field")
.into_value();
let ident = f.ident.as_ref().expect("Must have named fields");
let name = &s.ident;
let ty = &f.ty;