[][src]Enum libslide::evaluator_rules::rule::Rule

pub enum Rule {
    PatternMap(PatternMap),
    Evaluate(fn(_: RcExpr) -> Option<RcExpr>),
}

Variants

PatternMap(PatternMap)
Evaluate(fn(_: RcExpr) -> Option<RcExpr>)

Implementations

impl Rule[src]

pub fn from_fn(f: fn(_: RcExpr) -> Option<RcExpr>) -> Self[src]

pub fn from_str(s: &str) -> Self[src]

Trait Implementations

impl Debug for Rule[src]

impl Display for Rule[src]

impl Transformer<RcExpr, RcExpr> for Rule[src]

fn transform(&self, target: RcExpr) -> RcExpr[src]

Attempts to apply a rule on a target expression by

  1. Applying the rule recursively on the target's subexpression to obtain a partially-transformed target expression.

  2. Pattern matching the lhs of the rule with the partially-transformed target expression.

  • If pattern matching is unsuccessful, no application is done and the original expression is returned.
  1. Expanding the rhs of the rule using the results of the pattern matching.

Examples:

This example is not tested
"$x + 0 -> $x".try_apply("x + 0")  // Some(x)
"$x + 0 -> $x".try_apply("x + 1")  // None
"$x + 0 -> $x".try_apply("x")      // None

impl Transformer<RcExprPat, RcExprPat> for Rule[src]

fn transform(&self, target: RcExprPat) -> RcExprPat[src]

Bootstraps a rule with another (or possibly the same) rule.

Auto Trait Implementations

impl RefUnwindSafe for Rule

impl Send for Rule

impl Sync for Rule

impl Unpin for Rule

impl UnwindSafe for Rule

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.