Skip to content

Commit c2f0c11

Browse files
committed
Format
1 parent aad0f2e commit c2f0c11

1 file changed

Lines changed: 12 additions & 28 deletions

File tree

libraries/math-parser/src/parser.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ where
7474
let add_op = choice((just(Token::Plus).to(BinaryOp::Add), just(Token::Minus).to(BinaryOp::Sub)));
7575
let mul_op = choice((just(Token::Star).to(BinaryOp::Mul), just(Token::Slash).to(BinaryOp::Div), just(Token::Modulo).to(BinaryOp::Modulo)));
7676
let pow_op = just(Token::Caret).to(BinaryOp::Pow);
77-
let unary_op = choice((
78-
just(Token::Minus).to(UnaryOp::Neg),
79-
just(Token::Bang).to(UnaryOp::Not),
80-
));
77+
let unary_op = choice((just(Token::Minus).to(UnaryOp::Neg), just(Token::Bang).to(UnaryOp::Not)));
8178
let and_op = just(Token::AndAnd).to(BinaryOp::And);
8279
let or_op = just(Token::OrOr).to(BinaryOp::Or);
8380
let cmp_op = choice((
@@ -100,16 +97,7 @@ where
10097

10198
let pow = postfix.clone().foldl(
10299
pow_op
103-
.then(
104-
unary_op
105-
.clone()
106-
.repeated()
107-
.foldr(postfix, |op, expr| Node::UnaryOp {
108-
op,
109-
expr: Box::new(expr),
110-
})
111-
.boxed(),
112-
)
100+
.then(unary_op.clone().repeated().foldr(postfix, |op, expr| Node::UnaryOp { op, expr: Box::new(expr) }).boxed())
113101
.repeated(),
114102
|lhs, (op, rhs)| Node::BinOp {
115103
lhs: Box::new(lhs),
@@ -149,21 +137,17 @@ where
149137
rhs: Box::new(rhs),
150138
});
151139

152-
let and = chained_cmp
153-
.clone()
154-
.foldl(and_op.then(chained_cmp).repeated(), |lhs, (op, rhs)| Node::BinOp {
155-
lhs: Box::new(lhs),
156-
op,
157-
rhs: Box::new(rhs),
158-
});
140+
let and = chained_cmp.clone().foldl(and_op.then(chained_cmp).repeated(), |lhs, (op, rhs)| Node::BinOp {
141+
lhs: Box::new(lhs),
142+
op,
143+
rhs: Box::new(rhs),
144+
});
159145

160-
let or = and
161-
.clone()
162-
.foldl(or_op.then(and).repeated(), |lhs, (op, rhs)| Node::BinOp {
163-
lhs: Box::new(lhs),
164-
op,
165-
rhs: Box::new(rhs),
166-
});
146+
let or = and.clone().foldl(or_op.then(and).repeated(), |lhs, (op, rhs)| Node::BinOp {
147+
lhs: Box::new(lhs),
148+
op,
149+
rhs: Box::new(rhs),
150+
});
167151

168152
or
169153
})

0 commit comments

Comments
 (0)