Skip to main content

Match

Trait Match 

Source
pub trait Match<A: AstTypes> {
    // Required methods
    fn apply(&mut self, sub: &Subst<A>);
    fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool;

    // Provided methods
    fn apply_rule(&mut self, pat: &Self, template: &Self) -> bool
       where Self: Sized + Clone { ... }
    fn match_with(&self, pat: &Self) -> Option<Subst<A>> { ... }
}

Required Methods§

Source

fn apply(&mut self, sub: &Subst<A>)

With self as the pattern, recursively applies the Subst

Source

fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool

Implements recursive Subst-building for Self

Provided Methods§

Source

fn apply_rule(&mut self, pat: &Self, template: &Self) -> bool
where Self: Sized + Clone,

Applies a substitution rule from pat to template on self

Source

fn match_with(&self, pat: &Self) -> Option<Subst<A>>

Matches self against the provided pattern

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<A: AstTypes, T: Match<A>> Match<A> for Option<T>

Source§

fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool

Source§

fn apply(&mut self, sub: &Subst<A>)

Source§

impl<A: AstTypes, T: Match<A>> Match<A> for [T]

Source§

fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool

Source§

fn apply(&mut self, sub: &Subst<A>)

Source§

impl<A: AstTypes, T: Match<A>> Match<A> for Box<T>

Source§

fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool

Source§

fn apply(&mut self, sub: &Subst<A>)

Source§

impl<A: AstTypes, T: Match<A>> Match<A> for Vec<T>

Source§

fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool

Source§

fn apply(&mut self, sub: &Subst<A>)

Implementors§

Source§

impl<A: AstTypes> Match<A> for Expr<A>

Source§

impl<A: AstTypes> Match<A> for Op

Source§

impl<A: AstTypes> Match<A> for Pat<A>

Source§

impl<A: AstTypes> Match<A> for Bind<A>

Source§

impl<A: AstTypes> Match<A> for Make<A>

Source§

impl<A: AstTypes> Match<A> for MakeArm<A>

Source§

impl<A: AstTypes> Match<A> for Match<A>

Source§

impl<A: AstTypes> Match<A> for MatchArm<A>

Source§

impl<M: Match<A> + Annotation, A: AstTypes> Match<A> for At<M, A>