walk_expr_scoped_mut

Function walk_expr_scoped_mut 

pub fn walk_expr_scoped_mut<F>(expr: &mut Expr, scope_depth: usize, f: F)
where F: FnMut(&mut Expr, usize) -> bool,
Expand description

Walk an expression tree in pre-order, tracking scope depth through Let/Map scopes.

For each node, calls f(expr, scope_depth):

  • If f returns true, recursion into children continues.
  • If f returns false, children are skipped (e.g., when the callback has replaced the expression and doesn’t want to recurse into the replacement).

Scope depth rules:

  • Let bindings are visited at the current depth; the body at depth + 1
  • Map base is visited at the current depth; the map function at depth + 1
  • All other compound expressions: children at the same depth

This matches the semantics of ExprArg.nesting: an arg with nesting == scope_depth references the outermost (statement-level) scope, while nesting < scope_depth references a Let/Map binding.