Skip to content

Commit

Permalink
Add Visit::visit_children
Browse files Browse the repository at this point in the history
Summary: Useful in general.

Reviewed By: stepancheg

Differential Revision: D37270377

fbshipit-source-id: 1b4df108e047f79083e76776dd72e10b33ee39a2
  • Loading branch information
ndmitchell authored and facebook-github-bot committed Jun 20, 2022
1 parent d71cf20 commit bf693a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions starlark-rust/starlark/src/syntax/uniplate.rs
Expand Up @@ -36,6 +36,16 @@ pub(crate) enum VisitMut<'a, P: AstPayload> {
Expr(&'a mut AstExprP<P>),
}

impl<'a, P: AstPayload> Visit<'a, P> {
#[allow(dead_code)]
pub(crate) fn visit_children(&self, mut f: impl FnMut(Visit<'a, P>)) {
match self {
Self::Stmt(x) => x.visit_children(f),
Self::Expr(x) => x.visit_expr(|x| f(Visit::Expr(x))),
}
}
}

impl<P: AstPayload> StmtP<P> {
pub(crate) fn visit_children<'a>(&'a self, mut f: impl FnMut(Visit<'a, P>)) {
match self {
Expand Down

0 comments on commit bf693a6

Please sign in to comment.