pub struct VisitContext<'a, State> { /* private fields */ }Expand description
State and recursive operations available to a visit callback.
A matched callback owns traversal of its value. Recursive operations reborrow the visitor, so mutable state cannot remain borrowed across them.
Implementations§
Source§impl<State> VisitContext<'_, State>
impl<State> VisitContext<'_, State>
Sourcepub fn state_mut(&mut self) -> &mut State
pub fn state_mut(&mut self) -> &mut State
Mutably borrow the user state.
Sourcepub fn current(&self) -> &StructuralView
pub fn current(&self) -> &StructuralView
Complete borrowed value active at this callback.
Sourcepub fn def_region_kind(&self) -> DefRegionKind
pub fn def_region_kind(&self) -> DefRegionKind
Definition-region state active at the callback’s current value.
Sourcepub fn visit<T>(&mut self, child: &T) -> Result<Option<VisitInterrupt>>
pub fn visit<T>(&mut self, child: &T) -> Result<Option<VisitInterrupt>>
Visit child using the current definition-region state.
Sourcepub fn visit_with<T>(
&mut self,
child: &T,
def_region_kind: DefRegionKind,
) -> Result<Option<VisitInterrupt>>
pub fn visit_with<T>( &mut self, child: &T, def_region_kind: DefRegionKind, ) -> Result<Option<VisitInterrupt>>
Visit child using an explicit definition-region state.
Sourcepub fn visit_children(&mut self) -> Result<Option<VisitInterrupt>>
pub fn visit_children(&mut self) -> Result<Option<VisitInterrupt>>
Apply default descent without dispatching the current value again. A callback enters its configured policy; within a policy this continues with the next policy, then registered hooks or reflected fields.
Sourcepub fn default_visit_children<T>(
&mut self,
value: &T,
def_region_kind: DefRegionKind,
) -> Result<Option<VisitInterrupt>>
pub fn default_visit_children<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Option<VisitInterrupt>>
Apply default descent to value under an explicit definition region.
Like Self::visit_children, this continues with the next policy (or
enters the configured policy from a callback), then registered hooks or
reflected fields. It does not dispatch callbacks for value itself;
its children re-enter the full callback engine.
An enclosing DefRegionKind::Pattern cannot be downgraded. The current
value and region of this context are unchanged after the call, including
when descent returns an error or interrupt.