Expand description
This module defines a bunch of visitor wrappers, in the model described in the derive_generic_visitor crate.
Each such wrapper is a non-recursive visitor; the only thing it does is that its .visit()
method calls into the appropriate visit_foo of the wrapper, then continues visiting with
the wrapped visitor.
To use such a wrapper, just override the visit method of your visitor to call
TheWrapper::new(self).visit(x). This will integrate the wrapper into the normal behavior of
your visitor.
Each wrapper interacts with its wrapped visitor via a trait. To be able to use several wrappers at once, they must implement the wrapper-specific trait themselves and forward to their wrappee visitor. It’s a bit annoying as that potentially requires N^2 impls. I don’t know of a better design.
Structs§
- Dont
Leak Impl Details - Struct that we use to be able to use our visitor wrappers with each other to share
functionality, while still making the wrappers composable. We can implement e.g.
VisitorWithItem for DontLeakImplDetails<Wrapper<V>>while still retaining the capacity to implementimpl<V: VisitorWithItem> VisitorWithItem for Wrapper<V>that forwards to the inner visitor. - Visit
With Binder Depth - Visitor wrapper that tracks the depth of binders. To use it, make a visitor that implements
VisitorWithBinderDepthand override itsvisitfunction as follows: - Visit
With Binder Stack - Visitor wrapper that tracks the stack of binders seen so far. See
VisitWithBinderDepthfor how to use. - Visit
With Item - Visitor wrapper that adds item-generic
enter_itemandexit_itemmethods. - Visit
With Span - Visitor wrapper that tracks the current span. See
VisitWithBinderDepthfor how to use.