diff --git a/src/evaluate/function.rs b/src/evaluate/function.rs index 579032e..8aacd9d 100644 --- a/src/evaluate/function.rs +++ b/src/evaluate/function.rs @@ -28,7 +28,7 @@ fn to_radians(q: Quantity) -> Result { pub fn eval_function(g: &Expression) -> Result { - let Expression::Operator(loc, Operator::Function(f), args) = g else {panic!()}; + let Expression::Operator(loc, Operator::Function(f), args) = g else {unreachable!()}; if args.len() != 1 {panic!()}; let a = &args[0]; diff --git a/src/evaluate/mod.rs b/src/evaluate/mod.rs index d9078b6..18f6831 100644 --- a/src/evaluate/mod.rs +++ b/src/evaluate/mod.rs @@ -11,8 +11,8 @@ pub enum EvalError { ZeroDivision, IncompatibleUnit, IncompatibleUnits(String, String), - BadDefineName, - Undefined(String) + Undefined(String), + EvaluationError, } @@ -32,13 +32,13 @@ impl ToString for EvalError { String::from("Incompatible unit") }, EvalError::IncompatibleUnits(a, b) => { - format!("Incompatible units ({} and {})", a, b) - }, - EvalError::BadDefineName => { - String::from("Invalid variable name") + format!("Incompatible units ({a} and {b})") }, EvalError::Undefined(s) => { - format!("{} is undefined", s) + format!("{s} is undefined") + }, + EvalError::EvaluationError => { + String::from("Could not evaluate") } } }