Skip attribute if it is not wrapped with `template`

This commit is contained in:
Kogia-sima 2020-06-07 03:44:30 +09:00
parent 5b6b48f204
commit b24861e158
1 changed files with 4 additions and 2 deletions

View File

@ -135,8 +135,10 @@ fn derive_template_impl(tokens: TokenStream) -> Result<TokenStream, syn::Error>
let mut all_options = DeriveTemplateOptions::default();
for attr in strct.attrs {
let opt = syn::parse2::<DeriveTemplateOptions>(attr.tokens)?;
all_options.merge(opt)?;
if attr.path.is_ident("template") {
let opt = syn::parse2::<DeriveTemplateOptions>(attr.tokens)?;
all_options.merge(opt)?;
}
}
let mut template_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect(