Executes an implementation of `Visitor` in constant stack space. This function will visit every node in the given `Ast` while calling the appropriate methods provided by the [`Visitor`](trait.Visitor.html) trait. The primary use case for this method is when one wants to perform case analysis over an `Ast` without using a stack size proportional to the depth of the `Ast`. Namely, this method will
(ast: &Ast, visitor: V)
| 127 | /// If the visitor returns an error at any point, then visiting is stopped and |
| 128 | /// the error is returned. |
| 129 | pub fn visit<V: Visitor>(ast: &Ast, visitor: V) -> Result<V::Output, V::Err> { |
| 130 | HeapVisitor::new().visit(ast, visitor) |
| 131 | } |
| 132 | |
| 133 | /// HeapVisitor visits every item in an `Ast` recursively using constant stack |
| 134 | /// size and a heap size proportional to the size of the `Ast`. |