aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/input.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index cf1ad90..93d5e17 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -102,13 +102,20 @@ impl<'a> TemplateInput<'a> {
syn::Data::Struct(syn::DataStruct {
fields: syn::Fields::Named(ref fields),
..
- }) => fields.named.iter().filter_map(|f| {
- f.ident
- .as_ref()
- .and_then(|name| if name == "_parent" { Some(&f.ty) } else { None })
+ }) => fields.named.iter().find(|f| {
+ if let Some(field_name) = f.ident.as_ref() {
+ field_name == "_parent"
+ } else {
+ false
+ }
}),
_ => panic!("derive(Template) only works for struct items"),
- }.next();
+ };
+ let parent = if let Some(parent) = parent {
+ Some(&parent.ty)
+ } else {
+ None
+ };
TemplateInput {
ast,