Flatten a right-leaning AND expression tree into a list of conjuncts.
(expr: &ast::Expr, out: &mut Vec<ast::Expr>)
| 21 | |
| 22 | /// Flatten a right-leaning AND expression tree into a list of conjuncts. |
| 23 | pub fn flatten_and_expr(expr: &ast::Expr, out: &mut Vec<ast::Expr>) { |
| 24 | match expr { |
| 25 | ast::Expr::BinaryOp { |
| 26 | left, |
| 27 | op: ast::BinaryOperator::And, |
| 28 | right, |
| 29 | } => { |
| 30 | flatten_and_expr(left, out); |
| 31 | flatten_and_expr(right, out); |
| 32 | } |
| 33 | other => out.push(other.clone()), |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /// Reassemble conjuncts into a right-leaning AND tree. Panics if empty. |
| 38 | pub fn rebuild_and_expr(mut conjuncts: Vec<ast::Expr>) -> ast::Expr { |
no test coverage detected