pub trait RuleVisitor {
    type PatternVisitor: PatternVisitor;
    type ExprVisitor: ExprVisitor;
    type Expr;

    fn add_arg(
        &mut self,
        index: usize,
        ty: TypeId
    ) -> <Self::PatternVisitor as PatternVisitor>::PatternId; fn add_pattern<F>(&mut self, visitor: F)
    where
        F: FnOnce(&mut Self::PatternVisitor)
; fn add_expr<F>(&mut self, visitor: F) -> Self::Expr
    where
        F: FnOnce(&mut Self::ExprVisitor) -> VisitedExpr<Self::ExprVisitor>
; fn expr_as_pattern(
        &mut self,
        expr: Self::Expr
    ) -> <Self::PatternVisitor as PatternVisitor>::PatternId; fn pattern_as_expr(
        &mut self,
        pattern: <Self::PatternVisitor as PatternVisitor>::PatternId
    ) -> <Self::ExprVisitor as ExprVisitor>::ExprId; }
Expand description

Visitor interface for Rules. Visitors must be able to visit patterns by implementing PatternVisitor, and to visit expressions by providing a type that implements ExprVisitor.

Required Associated Types§

The type of pattern visitors constructed by RuleVisitor::add_pattern.

The type of expression visitors constructed by RuleVisitor::add_expr.

The type returned from RuleVisitor::add_expr, which may be exchanged for a subpattern identifier using RuleVisitor::expr_as_pattern.

Required Methods§

Visit one of the arguments to the top-level pattern.

Visit a pattern, used once for the rule’s left-hand side and once for each if-let. You can determine which part of the rule the pattern comes from based on whether the PatternId passed to the first call to this visitor came from add_arg or expr_as_pattern.

Visit an expression, used once for each if-let and once for the rule’s right-hand side.

Given an expression from RuleVisitor::add_expr, return an identifier that can be used with a pattern visitor in RuleVisitor::add_pattern.

Given an identifier from the pattern visitor, return an identifier that can be used with the expression visitor.

Implementors§