Struct xpr::Xpr [−][src]
pub struct Xpr<T>(_);
Expand description
An expression. Xpr
together with the Fold
trait are at the heart of this crate.
The nested type is a specific struct representing the operation, e.g. ops::Add
.
Xpr
instances should be instantiated via the Xpr::new
method, which creates
Xpr<ops::Term>
leaf expressions. The other variants are constructed from them by
applying operations to the leaf expressions.
use xpr::*;
let x = Xpr::new(5);
let y = Xpr::new(1);
let z = x * y;
//type of z is xpr::Xpr<xpr::ops::Mul<xpr::Xpr<xpr::ops::Term<{integer}>>, xpr::Xpr<xpr::ops::Term<{integer}>>>>
Implementations
evaluates the expression by unwrapping all terminals and applying the operations
in the expression. It is synactic sugar for folding the expression with [Evaluator
].
Trait Implementations
type Output = <T as Foldable<Self>>::Output
type Output = <T as Foldable<Self>>::Output
The output of Fold::fold
, Self
will replace all instances of T
in an expression by values of this type.
Auto Trait Implementations
impl<T> RefUnwindSafe for Xpr<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Xpr<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more