From 2355f4eb0b8fb33ef2d0994f4f54aa2615b8fa29 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 5 Feb 2017 15:15:40 +0100 Subject: Simplify writing of template struct impl --- askama/src/generator.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/askama/src/generator.rs b/askama/src/generator.rs index 3650ddb..61d4fab 100644 --- a/askama/src/generator.rs +++ b/askama/src/generator.rs @@ -204,22 +204,17 @@ impl Generator { } fn template_impl(&mut self, ast: &syn::DeriveInput, nodes: &Vec) { - self.write("impl"); let anno = annotations(&ast.generics); - self.write(&anno); - self.write(" askama::Template for "); - self.write(ast.ident.as_ref()); - self.write(&anno); - self.writeln(" {"); - + self.writeln(&format!("impl{} askama::Template for {}{} {{", + anno, ast.ident.as_ref(), anno)); self.indent(); + self.writeln("fn render_into(&self, writer: &mut std::fmt::Write) {"); self.indent(); - self.handle(nodes); - self.dedent(); self.writeln("}"); + self.dedent(); self.writeln("}"); } -- cgit