pull/2/head
Mark 2023-08-03 14:04:12 -07:00
parent 4ddafd84ef
commit ae2041e42f
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
2 changed files with 8 additions and 8 deletions

View File

@ -28,7 +28,7 @@ fn to_radians(q: Quantity) -> Result<Quantity, ()> {
pub fn eval_function(g: &Expression) -> Result<Expression, (LineLocation, EvalError)> { pub fn eval_function(g: &Expression) -> Result<Expression, (LineLocation, EvalError)> {
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!()}; if args.len() != 1 {panic!()};
let a = &args[0]; let a = &args[0];

View File

@ -11,8 +11,8 @@ pub enum EvalError {
ZeroDivision, ZeroDivision,
IncompatibleUnit, IncompatibleUnit,
IncompatibleUnits(String, String), IncompatibleUnits(String, String),
BadDefineName, Undefined(String),
Undefined(String) EvaluationError,
} }
@ -32,13 +32,13 @@ impl ToString for EvalError {
String::from("Incompatible unit") String::from("Incompatible unit")
}, },
EvalError::IncompatibleUnits(a, b) => { EvalError::IncompatibleUnits(a, b) => {
format!("Incompatible units ({} and {})", a, b) format!("Incompatible units ({a} and {b})")
},
EvalError::BadDefineName => {
String::from("Invalid variable name")
}, },
EvalError::Undefined(s) => { EvalError::Undefined(s) => {
format!("{} is undefined", s) format!("{s} is undefined")
},
EvalError::EvaluationError => {
String::from("Could not evaluate")
} }
} }
} }