# [−] [src] Trait regex_syntax::hir::Visitor

    pub trait Visitor {
        type Output;
        type Err;
        fn finish(self) -> Result<Self::Output, Self::Err>;

        fn start(&mut self) { ... }
        fn visit_pre(&mut self, _hir: &Hir) -> Result<(), Self::Err> { ... }
        fn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err> { ... }
        fn visit_alternation_in(&mut self) -> Result<(), Self::Err> { ... }
    }

A trait for visiting the high-level IR (HIR) in depth first order.

The principle aim of this trait is to enable callers to perform case analysis on a high-level intermediate representation of a regular expression without necessarily using recursion. In particular, this permits callers to do case analysis with constant stack usage, which can be important since the size of an HIR may be proportional to end user input.

Typical usage of this trait involves providing an implementation and then running it using the `visit` function.

## Associated Types

### `type Output`

The result of visiting an HIR.

### `type Err`

An error that visiting an HIR might return.

Loading content...

## Required methods

### `fn finish(self) -> Result<Self::Output, Self::Err>`

All implementors of `Visitor` must provide a `finish` method, which yields the result of visiting the HIR or an error.

Loading content...

## Provided methods

### `fn start(&mut self)`

This method is called before beginning traversal of the HIR.

### `fn visit_pre(&mut self, _hir: &Hir) -> Result<(), Self::Err>`

This method is called on an `Hir` before descending into child `Hir` nodes.

### `fn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err>`

This method is called on an `Hir` after descending all of its child `Hir` nodes.

### `fn visit_alternation_in(&mut self) -> Result<(), Self::Err>`

This method is called between child nodes of an alternation.

Loading content...

## Implementors

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)