diff --git a/src/global.rs b/src/global.rs index 3dddcd3..025b0f4 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1,6 +1,7 @@ pub const EULER: f64 = 2.718281828459045; pub const GOLDEN_RATIO: f64 = 1.618033988749895; +pub const LIGHT_SPEED: f64 = 299792458f64; pub const PI: f64 = 3.141592653589793; pub const ROOT_TWO: f64 = 1.414213562373095; diff --git a/src/helper.rs b/src/helper.rs index 02c57de..221147a 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -15,7 +15,7 @@ pub fn fix(arg: &Value) -> EvalResult { let count = args.len(); if count != 2 { - return Err(EvalexprError::WrongFunctionArgumentAmount { expected: 2, actual: count }); + return Err(EvalexprError::WrongFunctionArgumentAmount { expected: 2..=2, actual: count }); } let float = args[0].as_float()?; @@ -63,7 +63,7 @@ pub fn logarithm(arg: &Value) -> EvalResult { output = value.log(base).into(); }, _ => { - return Err(EvalexprError::WrongFunctionArgumentAmount { expected: 2, actual: count }); + return Err(EvalexprError::WrongFunctionArgumentAmount { expected: 2..=2, actual: count }); } } return Ok(output); diff --git a/src/main.rs b/src/main.rs index c0a5395..ed5bc0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ fn main() { // build eval context let mut context = context_map! { // globals + "c" => global::LIGHT_SPEED, "e" => global::EULER, "phi" => global::GOLDEN_RATIO, "pi" => global::PI,