From ffcbcd9f19b44a9ea65100e03d6ed5d96b22ce2c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 16 Aug 2017 20:54:48 +0200 Subject: Pass path to code generation as Path --- askama_derive/src/generator.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'askama_derive/src/generator.rs') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5eb456b..60d028b 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -4,12 +4,12 @@ use path; use quote::{Tokens, ToTokens}; use std::{cmp, hash, str}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::collections::HashSet; use syn; -pub fn generate(ast: &syn::DeriveInput, path: &str, mut nodes: Vec) -> String { +pub fn generate(ast: &syn::DeriveInput, path: &Path, mut nodes: Vec) -> String { let mut base: Option = None; let mut blocks = Vec::new(); let mut block_names = Vec::new(); @@ -52,16 +52,12 @@ pub fn generate(ast: &syn::DeriveInput, path: &str, mut nodes: Vec) -> Str gen.result() } -fn trait_name_for_path(base: &Option, path: &str) -> String { +fn trait_name_for_path(base: &Option, path: &Path) -> String { let rooted_path = match *base { Some(Expr::StrLit(user_path)) => { - path::find_template_from_path(user_path, Some(Path::new(path))) - }, - _ => { - let mut path_buf = PathBuf::new(); - path_buf.push(&path); - path_buf + path::find_template_from_path(user_path, Some(path)) }, + _ => path.to_path_buf(), }; let mut res = String::new(); -- cgit