aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-03-07 21:38:10 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-03-07 21:39:41 +0100
commitf229c795173db98c4552b0af11eb0a1b8c762ecc (patch)
tree6a9fa2147d55ed3d64eca6b787092c2826f1023d /askama_derive/src
parent4c8a5b51046c0f58f5a4c805794735bcd778eb8d (diff)
downloadaskama-f229c795173db98c4552b0af11eb0a1b8c762ecc.tar.gz
askama-f229c795173db98c4552b0af11eb0a1b8c762ecc.tar.bz2
askama-f229c795173db98c4552b0af11eb0a1b8c762ecc.zip
Inline annotations() helper into write_header()
Diffstat (limited to '')
-rw-r--r--askama_derive/src/generator.rs23
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 {