pub struct StructuralVisitorView<'a, D, Base = StructuralVisitorObj> { /* private fields */ }Expand description
The running structural visit, passed to each handler.
A handler that matches a node decides which children are visited: call
default_visit to visit every child,
visit to visit one value, or neither to skip the children.
Pass the handler’s own self as dispatch to every method. A handler
returns Ok(None) to continue, or Ok(Some(interrupt)) to stop the whole
visit with a VisitInterrupt.
See also structural_visit.
Implementations§
Source§impl<D, Base: StructuralVisitorBase> StructuralVisitorView<'_, D, Base>
impl<D, Base: StructuralVisitorBase> StructuralVisitorView<'_, D, Base>
Sourcepub fn def_region_kind(&self) -> DefRegionKind
pub fn def_region_kind(&self) -> DefRegionKind
Return the definition region the current value is in.
Reflected fields marked as definitions set it while their values are
visited; it is DefRegionKind::None elsewhere.
§Returns
The current definition region.
Sourcepub fn with_def_region_kind<R>(
&mut self,
kind: DefRegionKind,
callback: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_def_region_kind<R>( &mut self, kind: DefRegionKind, callback: impl FnOnce(&mut Self) -> R, ) -> R
Run callback under a scoped definition region.
An enclosing DefRegionKind::Pattern region keeps precedence; the
previous region is restored on all exits.
§Arguments
kind- The definition region to enter.callback- Runs inside the region, with this view.
§Returns
The result of callback.
Sourcepub fn visit<'input, T>(
&mut self,
dispatch: &mut D,
value: T,
) -> Result<Option<VisitInterrupt>>
pub fn visit<'input, T>( &mut self, dispatch: &mut D, value: T, ) -> Result<Option<VisitInterrupt>>
Sourcepub fn default_visit<'input, T>(
&self,
dispatch: &mut D,
value: T,
) -> Result<Option<VisitInterrupt>>
pub fn default_visit<'input, T>( &self, dispatch: &mut D, value: T, ) -> Result<Option<VisitInterrupt>>
Visit the children of value through the dispatcher, without dispatching
value itself again.
Children are found by the type’s registered visit hook or its reflected fields. A hook uses the visitor only through its arguments, during the call, and must not keep it or call it outside them. The visit stops at the first child that returns an interrupt.
§Arguments
dispatch- The handler’s ownself.value- The value whose children to visit.
§Returns
None to continue, or the interrupt that stopped the visit.
§Errors
Returns the first error of a child’s handler.