From 3b4c7e266bf9f2d1e6d23a190a8d45b77bd32e9b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 10 Aug 2017 12:37:25 +0200 Subject: Update debugging example in README --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f6271e9..f1fb0ae 100644 --- a/README.md +++ b/README.md @@ -141,14 +141,18 @@ Lit("", "!", "\n")] The generated code looks like this: ```rust -#[allow(dead_code, non_camel_case_types)] -impl<'a> askama::Template for HelloTemplate<'a> { - fn render_to(&self, writer: &mut std::fmt::Write) { - writer.write_str("Hello,").unwrap(); - writer.write_str(" ").unwrap(); - writer.write_fmt(format_args!("{}", self.name)).unwrap(); - writer.write_str("!").unwrap(); - writer.write_str("\n").unwrap(); +impl< 'a > ::askama::Template for HelloTemplate< 'a > { + fn render_into(&self, writer: &mut ::std::fmt::Write) -> Result<(), ::std::fmt::Error> { + writer.write_str("Hello,")?; + writer.write_str(" ")?; + writer.write_fmt(format_args!("{}", self.name))?; + writer.write_str("!")?; + Ok(()) + } +} +impl< 'a > ::std::fmt::Display for HelloTemplate< 'a > { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + self.render_into(f) } } ``` -- cgit