Evaluate in place expressions

This solution gives similar performance results than the tree based one,
mostly because of the intermediate vectors.
This commit is contained in:
2023-03-05 15:02:33 +01:00
parent ceefe1776d
commit b49d7b7995
4 changed files with 196 additions and 16 deletions

View File

@@ -68,6 +68,15 @@ pub enum Operator {
Divide,
}
impl Operator {
pub fn precedence(&self) -> u8 {
match self {
Operator::Add | Operator::Subtract => 1,
Operator::Multiply | Operator::Divide => 2,
}
}
}
impl fmt::Display for Operator {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {