[][src]Enum libslide::evaluator_rules::unbuilt_rule::UnbuiltRule

pub enum UnbuiltRule {
    S(&'static str),
    M(&'static [&'static str]),
    F(fn(_: RcExpr) -> Option<RcExpr>),
}

An unbuilt rule, generally used to express a rule in a human-readable form.

Variants

S(&'static str)

An expression-mapping rule.

A string rule is of the form

"<expr> -> <expr>"

Where is any expression pattern. An expression pattern is similar to any other expression, differing only in its pattern matching variables. The form of pattern matching variables and the expressions they match are as follows:

patternmatches
#A constant
$A variable
_Any expression

To apply a rule, the lhs of the rule is pattern matched on the target expression. If the matching is sucessful, the rhs of the rule is expanded with the results of the matching.

For example, the rule

"$a + 0 -> $a"

Applied on the expression "x + 0" would yield "x".

Note that mapping rules are built as, matched with, and applied on expression parse trees rather than the string representations of expressions. This ensures rule application is always exact and deterministic.

M(&'static [&'static str])

Multiple string rules. This should be used by rules that are only fully expressed by multiple similar transformations.

F(fn(_: RcExpr) -> Option<RcExpr>)

A function rule.

Trait Implementations

impl Clone for UnbuiltRule[src]

impl Copy for UnbuiltRule[src]

impl From<&'static str> for UnbuiltRule[src]

Auto Trait Implementations

impl RefUnwindSafe for UnbuiltRule

impl Send for UnbuiltRule

impl Sync for UnbuiltRule

impl Unpin for UnbuiltRule

impl UnwindSafe for UnbuiltRule

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.