aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Tuomas Siipola <tuomas@zpl.fi>2020-01-03 20:36:17 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-03 19:56:18 +0100
commitcef055108de6c51c1423cd6a8919730ef01f64a3 (patch)
tree1e2d2bbac73110453388b13ba781a1101803a37b /askama_derive/src/generator.rs
parent2446315d38882efe43a31a3749481eac9b25615d (diff)
downloadaskama-cef055108de6c51c1423cd6a8919730ef01f64a3.tar.gz
askama-cef055108de6c51c1423cd6a8919730ef01f64a3.tar.bz2
askama-cef055108de6c51c1423cd6a8919730ef01f64a3.zip
Support char literals
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 81f6ac9..9f60847 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -885,6 +885,7 @@ impl<'a> Generator<'a> {
Expr::BoolLit(s) => self.visit_bool_lit(buf, s),
Expr::NumLit(s) => self.visit_num_lit(buf, s),
Expr::StrLit(s) => self.visit_str_lit(buf, s),
+ Expr::CharLit(s) => self.visit_char_lit(buf, s),
Expr::Var(s) => self.visit_var(buf, s),
Expr::Path(ref path) => self.visit_path(buf, path),
Expr::Array(ref elements) => self.visit_array(buf, elements),
@@ -918,6 +919,7 @@ impl<'a> Generator<'a> {
expr_buf.write("&");
self.visit_str_lit(&mut expr_buf, s)
}
+ MatchVariant::CharLit(s) => self.visit_char_lit(&mut expr_buf, s),
MatchVariant::NumLit(s) => self.visit_num_lit(&mut expr_buf, s),
MatchVariant::Name(s) => {
expr_buf.write(s);
@@ -937,6 +939,7 @@ impl<'a> Generator<'a> {
let wrapped = match *param {
MatchParameter::NumLit(s) => self.visit_num_lit(&mut expr_buf, s),
MatchParameter::StrLit(s) => self.visit_str_lit(&mut expr_buf, s),
+ MatchParameter::CharLit(s) => self.visit_char_lit(&mut expr_buf, s),
MatchParameter::Name(s) => {
expr_buf.write(s);
DisplayWrap::Unwrapped
@@ -1155,6 +1158,11 @@ impl<'a> Generator<'a> {
DisplayWrap::Unwrapped
}
+ fn visit_char_lit(&mut self, buf: &mut Buffer, s: &str) -> DisplayWrap {
+ buf.write(&format!("'{}'", s));
+ DisplayWrap::Unwrapped
+ }
+
fn visit_num_lit(&mut self, buf: &mut Buffer, s: &str) -> DisplayWrap {
buf.write(s);
DisplayWrap::Unwrapped