diff options
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/input.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs index 683c345..ce004a8 100644 --- a/askama_derive/src/input.rs +++ b/askama_derive/src/input.rs @@ -100,20 +100,13 @@ impl<'a> TemplateInput<'a> { syn::Data::Struct(syn::DataStruct { fields: syn::Fields::Named(ref fields), .. - }) => fields.named.iter().find(|f| { - if let Some(field_name) = f.ident.as_ref() { - field_name == "_parent" - } else { - false - } - }), + }) => fields + .named + .iter() + .find(|f| f.ident.as_ref().filter(|name| *name == "_parent").is_some()) + .map(|f| &f.ty), _ => panic!("derive(Template) only works for struct items"), }; - let parent = if let Some(parent) = parent { - Some(&parent.ty) - } else { - None - }; TemplateInput { ast, |