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:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user