diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 12:37:25 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 12:37:25 +0200 |
commit | 3b4c7e266bf9f2d1e6d23a190a8d45b77bd32e9b (patch) | |
tree | 72ca093aeda33ed72803a2b27a8633e059e0e0a6 /README.md | |
parent | e8c47b7135a1ecf3414c6495b1cb592ae3e2d8a3 (diff) | |
download | askama-3b4c7e266bf9f2d1e6d23a190a8d45b77bd32e9b.tar.gz askama-3b4c7e266bf9f2d1e6d23a190a8d45b77bd32e9b.tar.bz2 askama-3b4c7e266bf9f2d1e6d23a190a8d45b77bd32e9b.zip |
Update debugging example in README
Diffstat (limited to '')
-rw-r--r-- | README.md | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -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) } } ``` |