diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:38:10 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:39:41 +0100 |
commit | f229c795173db98c4552b0af11eb0a1b8c762ecc (patch) | |
tree | 6a9fa2147d55ed3d64eca6b787092c2826f1023d /askama_derive/src/generator.rs | |
parent | 4c8a5b51046c0f58f5a4c805794735bcd778eb8d (diff) | |
download | askama-f229c795173db98c4552b0af11eb0a1b8c762ecc.tar.gz askama-f229c795173db98c4552b0af11eb0a1b8c762ecc.tar.bz2 askama-f229c795173db98c4552b0af11eb0a1b8c762ecc.zip |
Inline annotations() helper into write_header()
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r-- | askama_derive/src/generator.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5b7026d..af07470 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -3,19 +3,6 @@ use std::str; use std::collections::HashSet; use syn; -fn annotations(generics: &syn::Generics) -> String { - if generics.lifetimes.len() < 1 { - return String::new(); - } - let mut res = String::new(); - res.push('<'); - for lt in &generics.lifetimes { - res.push_str(lt.lifetime.ident.as_ref()); - } - res.push('>'); - res -} - fn path_as_identifier(s: &str) -> String { let mut res = String::new(); for c in s.chars() { @@ -321,7 +308,15 @@ impl<'a> Generator<'a> { fn write_header(&mut self, ast: &syn::DeriveInput, trait_suffix: Option<&str>) { - let anno = annotations(&ast.generics); + let mut anno = String::new(); + if ast.generics.lifetimes.len() > 0 { + anno.push('<'); + for lt in &ast.generics.lifetimes { + anno.push_str(lt.lifetime.ident.as_ref()); + } + anno.push('>'); + }; + let name = if trait_suffix.is_some() { format!("TraitFrom{}", trait_suffix.unwrap()) } else { |