diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-22 16:12:54 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-22 16:13:08 +0200 |
commit | 0889f86142e9cf86afd60da81041af4d2f94b70e (patch) | |
tree | b12822164cbacc6ad4aa04059f222ab4bcbad75c /askama_derive/src | |
parent | 3d75bcfe786e23be26302c5d39658d75d19468b7 (diff) | |
download | askama-0889f86142e9cf86afd60da81041af4d2f94b70e.tar.gz askama-0889f86142e9cf86afd60da81041af4d2f94b70e.tar.bz2 askama-0889f86142e9cf86afd60da81041af4d2f94b70e.zip |
Simplify trait names for blocks traits
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 6cf518a..938d9dc 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -8,7 +8,7 @@ use proc_macro2::Span; use quote::ToTokens; use std::collections::{HashMap, HashSet}; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::{cmp, hash, str}; use syn; @@ -81,7 +81,7 @@ impl<'a> Generator<'a> { } fn trait_blocks(&mut self, heritage: &Heritage<'a>) { - let trait_name = trait_name_for_path(&self.input.path); + let trait_name = format!("{}Blocks", self.input.ast.ident); self.writeln(&format!("pub trait {} {{", trait_name)); for name in heritage.blocks.keys() { self.writeln(&format!( @@ -919,19 +919,6 @@ impl<'a> Heritage<'a> { } } -fn trait_name_for_path(path: &Path) -> String { - let mut res = String::new(); - res.push_str("TraitFrom"); - for c in path.to_string_lossy().chars() { - if c.is_alphanumeric() { - res.push(c); - } else { - res.push_str(&format!("{:x}", c as u32)); - } - } - res -} - #[derive(Clone, PartialEq)] enum AstLevel { Top, |