mirror of https://github.com/rm-dr/daisy
Cleanup
parent
4ddafd84ef
commit
ae2041e42f
|
@ -28,7 +28,7 @@ fn to_radians(q: Quantity) -> Result<Quantity, ()> {
|
|||
|
||||
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!()};
|
||||
let a = &args[0];
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue