pub fn rewrite_expr<F>(expr: Expr, f: F) -> Result<Expr>where
    F: FnMut(Expr) -> Result<Expr>,
Expand description

Recursively rewrite an Expr via a function.

Rewrites the expression bottom up by recursively calling f(expr) on expr’s children and then on expr. See ExprRewriter for more details and more options to control the walk.

Example:

let expr = col("a") + lit(1);

// rewrite all literals to 42
let rewritten = rewrite_expr(expr, |e| {
  if let Expr::Literal(_) = e {
    Ok(lit(42))
  } else {
    Ok(e)
  }
}).unwrap();

assert_eq!(rewritten, col("a") + lit(42));