Module 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.

§Naming

Visitor methods follow this naming pattern:

[try_]visit_[mut_]{children,post,pre}
  • 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.

Structs§

StackSafeVisit 🔒

Traits§

TryVisitor
TryVisitorMut
Visit
A trait for types that can recursively visit their children of the same type.
VisitChildren
A trait for types that can visit their direct children of type T.
Visitor
VisitorMut