diff --git a/src/calc.rs b/src/calc.rs index 6fef4f1..1444142 100644 --- a/src/calc.rs +++ b/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 { + let first_split: Vec<&str> = expression.split_inclusive(['+', '-', '*', '/']).collect(); +}