Simplify code.

This commit is contained in:
Stephen Chung
2020-04-11 18:09:03 +08:00
parent 5848339d5a
commit bc0d43d68f
3 changed files with 102 additions and 116 deletions

View File

@@ -2192,11 +2192,10 @@ fn parse_binary_op<'a>(
let mut current_lhs = lhs;
loop {
let (current_precedence, bind_right) = if let Some((current_op, _)) = input.peek() {
(current_op.precedence(), current_op.is_bind_right())
} else {
(0, false)
};
let (current_precedence, bind_right) = input.peek().map_or_else(
|| (0, false),
|(current_op, _)| (current_op.precedence(), current_op.is_bind_right()),
);
// Bind left to the parent lhs expression if precedence is higher
// If same precedence, then check if the operator binds right