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)> {
|
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];
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue