parse thse what sir
This commit is contained in:
11
src/calc.rs
11
src/calc.rs
@@ -91,7 +91,13 @@ impl CalcTree {
|
||||
match operation {
|
||||
Operation::Add => Num(a + b),
|
||||
Operation::Sub => Num(a - b),
|
||||
Operation::Div => Num(a / b),
|
||||
Operation::Div => {
|
||||
if b != 0 {
|
||||
Num(a / b)
|
||||
} else {
|
||||
panic!("DIVISION BY 0");
|
||||
}
|
||||
}
|
||||
Operation::Mult => Num(a * b),
|
||||
}
|
||||
} else {
|
||||
@@ -99,3 +105,6 @@ impl CalcTree {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn parse_string(expression: &str) -> Vec<Item> {
|
||||
let first_split: Vec<&str> = expression.split_inclusive(['+', '-', '*', '/']).collect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user