pub struct Operator<'a, T: Clone> { /* private fields */ }
Expand description
Operators can be unary such as sin
, binary such as *
, unary and binary such as -
,
or constants such as π
. To use custom operators, see the short-cut-macro ops_factory
implement the trait MakeOperators
directly.
Implementations§
source§impl<'a, T: Clone> Operator<'a, T>
impl<'a, T: Clone> Operator<'a, T>
sourcepub fn make_unary(repr: &'a str, unary_op: fn(_: T) -> T) -> Operator<'a, T>
pub fn make_unary(repr: &'a str, unary_op: fn(_: T) -> T) -> Operator<'a, T>
Creates a unary operator.
sourcepub fn make_bin_unary(
repr: &'a str,
bin_op: BinOp<T>,
unary_op: fn(_: T) -> T
) -> Operator<'a, T>
pub fn make_bin_unary( repr: &'a str, bin_op: BinOp<T>, unary_op: fn(_: T) -> T ) -> Operator<'a, T>
Creates an operator that is either unary or binary based on its positioning in the string to be parsed.
For instance, -
as defined in FloatOpsFactory
is unary in -x
and binary
in 2-x
.
sourcepub fn make_constant(repr: &'a str, constant: T) -> Operator<'a, T>
pub fn make_constant(repr: &'a str, constant: T) -> Operator<'a, T>
Creates a constant operator. If an operator is constant it cannot be additionally binary or unary.
pub fn bin(&self) -> ExResult<BinOp<T>>
pub fn unary(&self) -> ExResult<fn(_: T) -> T>
pub fn repr(&self) -> &'a str
pub fn has_bin(&self) -> bool
pub fn has_unary(&self) -> bool
pub fn constant(&self) -> Option<T>
Trait Implementations§
source§impl<'a, T: Ord + Clone> Ord for Operator<'a, T>
impl<'a, T: Ord + Clone> Ord for Operator<'a, T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<'a, T: PartialEq + Clone> PartialEq for Operator<'a, T>
impl<'a, T: PartialEq + Clone> PartialEq for Operator<'a, T>
source§impl<'a, T: PartialOrd + Clone> PartialOrd for Operator<'a, T>
impl<'a, T: PartialOrd + Clone> PartialOrd for Operator<'a, T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'a, T: Eq + Clone> Eq for Operator<'a, T>
impl<'a, T: Clone> StructuralEq for Operator<'a, T>
impl<'a, T: Clone> StructuralPartialEq for Operator<'a, T>
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for Operator<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Operator<'a, T>where
T: Send,
impl<'a, T> Sync for Operator<'a, T>where
T: Sync,
impl<'a, T> Unpin for Operator<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for Operator<'a, T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more