Update evalexpr dependency

This commit is contained in:
Magnus Ulimoen 2021-07-06 22:10:33 +02:00
parent b9212a4ec3
commit e4ea5b081b
2 changed files with 1 additions and 65 deletions

View File

@ -17,4 +17,4 @@ serde = { version = "1.0.115", features = ["derive"] }
json5 = "0.3.0" json5 = "0.3.0"
indexmap = { version = "1.5.2", features = ["serde-1"] } indexmap = { version = "1.5.2", features = ["serde-1"] }
argh = "0.1.4" argh = "0.1.4"
evalexpr = "6.2.0" evalexpr = "6.3.0"

View File

@ -359,69 +359,5 @@ pub fn default_context() -> HashMapContext {
) )
.unwrap(); .unwrap();
context
.set_function(
"math::atan2".into(),
Function::new(|arg| {
let arg = arg.as_tuple()?;
if arg.len() != 2 {
return Err(error::EvalexprError::WrongFunctionArgumentAmount {
expected: 2,
actual: arg.len(),
});
}
let s = arg[0].as_number()?;
let o = arg[1].as_number()?;
Ok(s.atan2(o).into())
}),
)
.unwrap();
context
.set_function(
"math::hypot".into(),
Function::new(|arg| {
let arg = arg.as_tuple()?;
if arg.len() != 2 {
return Err(error::EvalexprError::WrongFunctionArgumentAmount {
expected: 2,
actual: arg.len(),
});
}
let s = arg[0].as_number()?;
let o = arg[1].as_number()?;
Ok(s.hypot(o).into())
}),
)
.unwrap();
context
.set_function(
"math::exp".into(),
Function::new(|arg| {
let arg = arg.as_number()?;
Ok(arg.exp().into())
}),
)
.unwrap();
context
.set_function(
"math::pow".into(),
Function::new(|arg| {
let arg = arg.as_tuple()?;
if arg.len() != 2 {
return Err(error::EvalexprError::WrongFunctionArgumentAmount {
expected: 2,
actual: arg.len(),
});
}
let s = arg[0].as_number()?;
let o = arg[1].as_number()?;
Ok(s.powf(o).into())
}),
)
.unwrap();
context context
} }