From 0889f86142e9cf86afd60da81041af4d2f94b70e Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 22 Jun 2018 16:12:54 +0200 Subject: Simplify trait names for blocks traits --- askama_derive/src/generator.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'askama_derive/src') 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, -- cgit