mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
Inline annotations() helper into write_header()
This commit is contained in:
parent
4c8a5b5104
commit
f229c79517
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user