pub fn transform<F>(expr: Expression, fun: &F) -> Result<Expression>Expand description
Transforms an expression tree bottom-up, with optional node removal.
Recursively transforms all children first, then applies fun to the resulting node.
If fun returns Ok(None), the node is replaced with an Expression::Null.
If fun returns Ok(Some(expr)), the node is replaced with expr.
This is the primary transformation entry point when callers need the ability to
“delete” nodes by returning None.
§Example
ⓘ
use polyglot_sql::traversal::transform;
// Remove all Paren wrapper nodes from a tree
let result = transform(expr, &|e| match e {
Expression::Paren(p) => Ok(Some(p.this)),
other => Ok(Some(other)),
})?;