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 also the macro ops_factory
.
Implementations
sourceimpl<'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
sourceimpl<'a, T: Ord + Clone> Ord for Operator<'a, T>
impl<'a, T: Ord + Clone> Ord for Operator<'a, T>
sourceimpl<'a, T: PartialOrd + Clone> PartialOrd<Operator<'a, T>> for Operator<'a, T>
impl<'a, T: PartialOrd + Clone> PartialOrd<Operator<'a, T>> for Operator<'a, T>
sourcefn partial_cmp(&self, other: &Operator<'a, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Operator<'a, T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl<'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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more