aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-04 20:31:28 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-04 20:31:28 +0200
commit6145cb5a4878b711b075da3759c2c60307fb43b2 (patch)
tree1f78f933e9e20093c70cc0aff406295907c77f4b /askama_shared/src
parent9a21f5eaa3920c51371ee5bd0634e148d825dd71 (diff)
downloadaskama-6145cb5a4878b711b075da3759c2c60307fb43b2.tar.gz
askama-6145cb5a4878b711b075da3759c2c60307fb43b2.tar.bz2
askama-6145cb5a4878b711b075da3759c2c60307fb43b2.zip
Clean up and tighten faster version of expr_prec_layer macro
Diffstat (limited to '')
-rw-r--r--askama_shared/src/parser.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs
index 8ff2063..1156b68 100644
--- a/askama_shared/src/parser.rs
+++ b/askama_shared/src/parser.rs
@@ -229,21 +229,16 @@ named!(expr_filtered<Expr>, do_parse!(
macro_rules! expr_prec_layer {
( $name:ident, $inner:ident, $( $op:expr ),* ) => {
- named!($name<Expr>,
- do_parse!(
- left: $inner >>
- op_and_right: opt!(pair!(ws!(alt!($( tag_s!($op) )|*)), expr_any)) >>
- (
- if op_and_right.is_some() {
- let (op, right) = op_and_right.unwrap();
- (Expr::BinOp(str::from_utf8(op).unwrap(),
- Box::new(left), Box::new(right)))
- } else {
- left
- }
- )
- )
- );
+ named!($name<Expr>, do_parse!(
+ left: $inner >>
+ op_and_right: opt!(pair!(ws!(alt!($( tag_s!($op) )|*)), expr_any)) >>
+ (match op_and_right {
+ Some((op, right)) => Expr::BinOp(
+ str::from_utf8(op).unwrap(), Box::new(left), Box::new(right)
+ ),
+ None => left,
+ })
+ ));
}
}