Skip to content

Commit c30a8aa

Browse files
committed
Code review
1 parent 01bc772 commit c30a8aa

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

libraries/math-parser/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ mod tests {
8585
}
8686

8787
test_end_to_end! {
88-
// Basic arithmetic and units
88+
// Basic arithmetic
8989
infix_addition: "5 + 5" => 10.,
90+
infix_subtraction_units: "5 - 3" => 2.,
91+
infix_multiplication_units: "4 * 4" => 16.,
92+
infix_division_units: "8/2" => 4.,
9093

9194
// Order of operations
9295
order_of_operations_negative_prefix: "-10 + 5" => -5.,

libraries/math-parser/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub fn chumsky_parser<'a>() -> impl Parser<'a, &'a str, Node, chumsky::extra::Er
5252
just("e").map(|_| Node::Lit(Literal::Float(std::f64::consts::E))),
5353
just("phi").or(just("φ")).map(|_| Node::Lit(Literal::Float(1.618_033_988_75))),
5454
just("inf").or(just("∞")).map(|_| Node::Lit(Literal::Float(f64::INFINITY))),
55-
just("i").map(|_| Node::Lit(Literal::Complex(Complex::new(0.0, 1.0)))), // Assuming Complex impl
56-
just("G").map(|_| Node::Lit(Literal::Float(9.80665))), // gravity
55+
just("i").map(|_| Node::Lit(Literal::Complex(Complex::new(0.0, 1.0)))), // Assuming `Complex` impl
56+
just("G").map(|_| Node::Lit(Literal::Float(9.80665))), // Standard gravity on Earth
5757
));
5858

5959
let ident = text::ident().padded();

libraries/math-parser/src/value.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ impl Number {
6262
BinaryOp::Div => lhs / rhs,
6363
BinaryOp::Pow => lhs.powf(rhs),
6464
BinaryOp::Leq => (lhs <= rhs) as u8 as f64,
65-
BinaryOp::Lt => {
66-
println!("{lhs} < {rhs}: {}", (lhs < rhs) as u8);
67-
(lhs < rhs) as u8 as f64
68-
}
65+
BinaryOp::Lt => (lhs < rhs) as u8 as f64,
6966
BinaryOp::Geq => (lhs >= rhs) as u8 as f64,
7067
BinaryOp::Gt => (lhs > rhs) as u8 as f64,
7168
BinaryOp::Eq => (lhs == rhs) as u8 as f64,

0 commit comments

Comments
 (0)