Trait exmex::MakeOperators [−][src]
Expand description
To use custom operators one needs to create a factory that implements this trait.
In this way, we make sure that we can deserialize expressions with
serde
with the correct operators based on the type.
Example
use exmex::{BinOp, MakeOperators, Operator};
#[derive(Clone)]
struct SomeOpsFactory;
impl MakeOperators<f32> for SomeOpsFactory {
fn make<'a>() -> Vec<Operator<'a, f32>> {
vec![
Operator::make_bin_unary(
"-",
BinOp {
apply: |a, b| a - b,
prio: 0,
is_commutative: false,
},
|a| (-a),
),
Operator::make_unary("sin", |a| a.sin())
]
}
}