From dbb48dbbf2647100f6e3db5d4ae0ec920722eca4 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 16 Jun 2018 13:32:38 +0200 Subject: Move code around to enforce structure --- askama_derive/src/generator.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'askama_derive/src/generator.rs') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index fb529a0..0d3dd5f 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -108,24 +108,6 @@ fn trait_name_for_path(path: &Path) -> String { res } -fn get_parent_type(ast: &syn::DeriveInput) -> Option<&syn::Type> { - match ast.data { - 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 - } - }) - }), - _ => panic!("derive(Template) only works for struct items"), - }.next() -} - struct Generator<'a> { buf: String, indent: u8, @@ -974,6 +956,24 @@ impl<'a, T: 'a> SetChain<'a, T> where T: cmp::Eq + hash::Hash { } } +fn get_parent_type(ast: &syn::DeriveInput) -> Option<&syn::Type> { + match ast.data { + 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 + } + }) + }), + _ => panic!("derive(Template) only works for struct items"), + }.next() +} + #[derive(Clone)] enum AstLevel { Top, -- cgit