From 715eed3aeeb8e5d0cbb420239432cda69e6131f8 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 5 Feb 2017 10:13:22 +0100 Subject: Improve name and ownership of AST vector --- askama/src/generator.rs | 12 ++++++------ askama_derive/src/lib.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/askama/src/generator.rs b/askama/src/generator.rs index f262f7c..4c91d14 100644 --- a/askama/src/generator.rs +++ b/askama/src/generator.rs @@ -147,8 +147,8 @@ impl Generator { } } - fn handle(&mut self, tokens: &Vec) { - for n in tokens { + fn handle(&mut self, nodes: &Vec) { + for n in nodes { match n { &Node::Lit(val) => { self.write_lit(val); }, &Node::Expr(ref val) => { self.write_expr(&val); }, @@ -173,7 +173,7 @@ impl Generator { res } - fn template_impl(&mut self, ast: &syn::DeriveInput, tokens: &Vec) { + fn template_impl(&mut self, ast: &syn::DeriveInput, nodes: &Vec) { self.write("impl"); let anno = self.annotations(&ast.generics); self.write(&anno); @@ -186,7 +186,7 @@ impl Generator { self.writeln("fn render_into(&self, writer: &mut std::fmt::Write) {"); self.indent(); - self.handle(tokens); + self.handle(nodes); self.dedent(); self.writeln("}"); @@ -200,8 +200,8 @@ impl Generator { } -pub fn generate(ast: &syn::DeriveInput, tokens: &Vec) -> String { +pub fn generate(ast: &syn::DeriveInput, nodes: Vec) -> String { let mut gen = Generator::new(); - gen.template_impl(ast, tokens); + gen.template_impl(ast, &nodes); gen.result() } diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index cdb0dd9..03bfe7d 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -58,6 +58,6 @@ pub fn derive_template(input: TokenStream) -> TokenStream { let path = get_path_from_attrs(&ast.attrs); let src = get_template_source(&path); - let tokens = askama::parser::parse(&src); - askama::generator::generate(&ast, &tokens).parse().unwrap() + let nodes = askama::parser::parse(&src); + askama::generator::generate(&ast, nodes).parse().unwrap() } -- cgit