Module mz_expr::visit

source ·
Expand description

Visitor support for recursive data types.

Recursive types can implement the VisitChildren trait, to specify how their recursive entries can be accessed. The extension trait Visit then adds support for recursively traversing instances of those types.


Visitor methods follow this naming pattern:

  • The try-prefix specifies whether the visitor callback is fallible (prefix present) or infallible (prefix omitted).
  • The mut-suffix specifies whether the visitor callback gets access to mutable (prefix present) or immutable (prefix omitted) child references.
  • The final suffix determines the nature of the traversal:
    • children: only visit direct children
    • post: recursively visit children in post-order
    • pre: recursively visit children in pre-order
    • no suffix: recursively visit children in pre- and post-oder using a Visitor` that encapsulates the shared context.