Skip to main content

StructuralVisitorView

Struct StructuralVisitorView 

Source
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>

Source

pub fn base(&self) -> &Base

Inspect the base state; the borrow cannot outlive this view.

Source

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.

Source

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.

Source

pub fn visit<'input, T>( &mut self, dispatch: &mut D, value: T, ) -> Result<Option<VisitInterrupt>>
where T: Into<AnyView<'input>>,

Visit value through the dispatcher, as if the traversal had reached it.

§Arguments
  • dispatch - The handler’s own self.
  • value - The value to visit.
§Returns

None to continue, or the interrupt that stopped the visit.

§Errors

Returns the error of the handler that value reaches.

Source

pub fn default_visit<'input, T>( &self, dispatch: &mut D, value: T, ) -> Result<Option<VisitInterrupt>>
where T: Into<AnyView<'input>>,

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 own self.
  • 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.

Auto Trait Implementations§

§

impl<'a, D, Base = StructuralVisitorObj> !RefUnwindSafe for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base = StructuralVisitorObj> !Send for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base = StructuralVisitorObj> !Sync for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base = StructuralVisitorObj> !UnwindSafe for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base> Freeze for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base> Unpin for StructuralVisitorView<'a, D, Base>

§

impl<'a, D, Base> UnsafeUnpin for StructuralVisitorView<'a, D, Base>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeSubsumes<T> for T
where T: ?Sized,