Skip to main content

RewriteRule

Trait RewriteRule 

Source
pub trait RewriteRule: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn apply(&self, expr: &TLExpr) -> Option<TLExpr>;

    // Provided method
    fn is_recursive(&self) -> bool { ... }
}
Expand description

A single pattern-matching rewrite rule.

Implementors inspect an expression and, if the rule matches, return a transformed replacement expression. If the rule does not apply, None is returned and the engine tries the next rule.

Required Methods§

Source

fn name(&self) -> &'static str

Unique human-readable name used in statistics output.

Source

fn apply(&self, expr: &TLExpr) -> Option<TLExpr>

Try to apply this rule to expr.

Returns Some(new_expr) when the rule fires, None otherwise.

Provided Methods§

Source

fn is_recursive(&self) -> bool

Whether the engine should recurse into children of expr before trying this rule. Defaults to true (standard bottom-up traversal).

Implementors§