diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-16 13:32:38 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-16 13:32:38 +0200 |
commit | dbb48dbbf2647100f6e3db5d4ae0ec920722eca4 (patch) | |
tree | 79f5212555e26122c7b05d96e507e4c4113cf05d /askama_derive/src | |
parent | 305ce1dd38692285e79eeacacbc9514d1df4055b (diff) | |
download | askama-dbb48dbbf2647100f6e3db5d4ae0ec920722eca4.tar.gz askama-dbb48dbbf2647100f6e3db5d4ae0ec920722eca4.tar.bz2 askama-dbb48dbbf2647100f6e3db5d4ae0ec920722eca4.zip |
Move code around to enforce structure
Diffstat (limited to 'askama_derive/src')
-rw-r--r-- | askama_derive/src/generator.rs | 36 |
1 files changed, 18 insertions, 18 deletions
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, |