Struct exmex::Operator [−][src]
pub struct Operator<'a, T> {
pub repr: &'a str,
pub bin_op: Option<BinOp<T>>,
pub unary_op: Option<fn(_: T) -> T>,
}Expand description
Operators can be custom-defined by the library-user in terms of this struct.
Examples
use exmex::{BinOp, Operator};
let ops = vec![
Operator {
repr: "-",
bin_op: Some(BinOp {
apply: |a, b| a - b,
prio: 0,
}),
unary_op: Some(|a: f32| (-a)),
},
Operator {
repr: "sin",
bin_op: None,
unary_op: Some(|a: f32| a.sin()),
}
];Fields
repr: &'a strRepresentation of the operator in the string to be parsed, e.g., - or sin.
bin_op: Option<BinOp<T>>Binary operator that contains a priority besides a function pointer, if available.
unary_op: Option<fn(_: T) -> T>Unary operator that does not have an explicit priority. Unary operators have
higher priority than binary opertors, e.g., -1^2 == 1.
Trait Implementations
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Operator<'a, T>
impl<'a, T> UnwindSafe for Operator<'a, T>
Blanket Implementations
Mutably borrows from an owned value. Read more