fn to_aexpr(expr: Expr, arena: &mut Arena<AExpr>) -> Node {
    let v = match expr {
        Expr::Unique(expr) => AExpr::Unique(to_aexpr(*expr, arena)),
        Expr::Duplicated(expr) => AExpr::Duplicated(to_aexpr(*expr, arena)),
        Expr::Reverse(expr) => AExpr::Reverse(to_aexpr(*expr, arena)),
        Expr::Alias(e, name) => AExpr::Alias(to_aexpr(*e, arena), name),
        Expr::Literal(value) => AExpr::Literal(value),
        Expr::Column(s) => AExpr::Column(s),
        Expr::BinaryExpr { left, op, right } => {
            let l = to_aexpr(*left, arena);
            let r = to_aexpr(*right, arena);
            AExpr::BinaryExpr {
                left: l,
                op,
                right: r,
            }
        }
        Expr::Not(e) => AExpr::Not(to_aexpr(*e, arena)),
        Expr::IsNotNull(e) => AExpr::IsNotNull(to_aexpr(*e, arena)),
        Expr::IsNull(e) => AExpr::IsNull(to_aexpr(*e, arena)),

        Expr::Cast { expr, data_type } => AExpr::Cast {
            expr: to_aexpr(*expr, arena),
            data_type,
        },
        Expr::Sort { expr, reverse } => AExpr::Sort {
            expr: to_aexpr(*expr, arena),
            reverse,
        },
        Expr::AggMin(expr) => AExpr::AggMin(to_aexpr(*expr, arena)),
        Expr::AggMax(expr) => AExpr::AggMax(to_aexpr(*expr, arena)),
        Expr::AggMedian(expr) => AExpr::AggMedian(to_aexpr(*expr, arena)),
        Expr::AggNUnique(expr) => AExpr::AggNUnique(to_aexpr(*expr, arena)),
        Expr::AggFirst(expr) => AExpr::AggFirst(to_aexpr(*expr, arena)),
        Expr::AggLast(expr) => AExpr::AggLast(to_aexpr(*expr, arena)),
        Expr::AggMean(expr) => AExpr::AggMean(to_aexpr(*expr, arena)),
        Expr::AggList(expr) => AExpr::AggList(to_aexpr(*expr, arena)),
        Expr::AggCount(expr) => AExpr::AggCount(to_aexpr(*expr, arena)),
        Expr::AggQuantile { expr, quantile } => AExpr::AggQuantile {
            expr: to_aexpr(*expr, arena),
            quantile,
        },
        Expr::AggSum(expr) => AExpr::AggSum(to_aexpr(*expr, arena)),
        Expr::AggGroups(expr) => AExpr::AggGroups(to_aexpr(*expr, arena)),
        Expr::Ternary {
            predicate,
            truthy,
            falsy,
        } => {
            let p = to_aexpr(*predicate, arena);
            let t = to_aexpr(*truthy, arena);
            let f = to_aexpr(*falsy, arena);
            AExpr::Ternary {
                predicate: p,
                truthy: t,
                falsy: f,
            }
        }
        Expr::Apply {
            input,
            function,
            output_type,
        } => AExpr::Apply {
            input: to_aexpr(*input, arena),
            function,
            output_type,
        },
        Expr::Shift { input, periods } => AExpr::Shift {
            input: to_aexpr(*input, arena),
            periods,
        },
        Expr::Wildcard => AExpr::Wildcard,
    };
    arena.add(v)
}
// converts expression to AExpr, which uses an arena (Vec) for allocation
converts expression to AExpr, which uses an arena (Vec) for allocation
converts expression to AExpr which uses an arena ( Vec ) for allocation
fn to_aexpr(expr: Expr, arena: &mut Arena<AExpr>) -> Node {
    let v = match expr {
        Expr::Unique(expr) => AExpr::Unique(to_aexpr(*expr, arena)),
        Expr::Duplicated(expr) => AExpr::Duplicated(to_aexpr(*expr, arena)),
        Expr::Reverse(expr) => AExpr::Reverse(to_aexpr(*expr, arena)),
        Expr::Alias(e, name) => AExpr::Alias(to_aexpr(*e, arena), name),
        Expr::Literal(value) => AExpr::Literal(value),
        Expr::Column(s) => AExpr::Column(s),
        Expr::BinaryExpr { left, op, right } => {
            let l = to_aexpr(*left, arena);
            let r = to_aexpr(*right, arena);
            AExpr::BinaryExpr {
                left: l,
                op,
                right: r,
            }
        }
        Expr::Not(e) => AExpr::Not(to_aexpr(*e, arena)),
        Expr::IsNotNull(e) => AExpr::IsNotNull(to_aexpr(*e, arena)),
        Expr::IsNull(e) => AExpr::IsNull(to_aexpr(*e, arena)),
        Expr::Cast { expr, data_type } => AExpr::Cast {
            expr: to_aexpr(*expr, arena),
            data_type,
        },
        Expr::Sort { expr, reverse } => AExpr::Sort {
            expr: to_aexpr(*expr, arena),
            reverse,
        },
        Expr::AggMin(expr) => AExpr::AggMin(to_aexpr(*expr, arena)),
        Expr::AggMax(expr) => AExpr::AggMax(to_aexpr(*expr, arena)),
        Expr::AggMedian(expr) => AExpr::AggMedian(to_aexpr(*expr, arena)),
        Expr::AggNUnique(expr) => AExpr::AggNUnique(to_aexpr(*expr, arena)),
        Expr::AggFirst(expr) => AExpr::AggFirst(to_aexpr(*expr, arena)),
        Expr::AggLast(expr) => AExpr::AggLast(to_aexpr(*expr, arena)),
        Expr::AggMean(expr) => AExpr::AggMean(to_aexpr(*expr, arena)),
        Expr::AggList(expr) => AExpr::AggList(to_aexpr(*expr, arena)),
        Expr::AggCount(expr) => AExpr::AggCount(to_aexpr(*expr, arena)),
        Expr::AggQuantile { expr, quantile } => AExpr::AggQuantile {
            expr: to_aexpr(*expr, arena),
            quantile,
        },
        Expr::AggSum(expr) => AExpr::AggSum(to_aexpr(*expr, arena)),
        Expr::AggGroups(expr) => AExpr::AggGroups(to_aexpr(*expr, arena)),
        Expr::Ternary {
            predicate,
            truthy,
            falsy,
        } => {
            let p = to_aexpr(*predicate, arena);
            let t = to_aexpr(*truthy, arena);
            let f = to_aexpr(*falsy, arena);
            AExpr::Ternary {
                predicate: p,
                truthy: t,
                falsy: f,
            }
        }
        Expr::Apply {
            input,
            function,
            output_type,
        } => AExpr::Apply {
            input: to_aexpr(*input, arena),
            function,
            output_type,
        },
        Expr::Shift { input, periods } => AExpr::Shift {
            input: to_aexpr(*input, arena),
            periods,
        },
        Expr::Wildcard => AExpr::Wildcard,
    };
    arena.add(v)
}
fn to_aexpr ( expr : Expr , arena : & mut Arena < AExpr > ) -> Node { let v = match expr { Expr :: Unique ( expr ) => AExpr :: Unique ( to_aexpr ( * expr , arena ) ) , Expr :: Duplicated ( expr ) => AExpr :: Duplicated ( to_aexpr ( * expr , arena ) ) , Expr :: Reverse ( expr ) => AExpr :: Reverse ( to_aexpr ( * expr , arena ) ) , Expr :: Alias ( e , name ) => AExpr :: Alias ( to_aexpr ( * e , arena ) , name ) , Expr :: Literal ( value ) => AExpr :: Literal ( value ) , Expr :: Column ( s ) => AExpr :: Column ( s ) , Expr :: BinaryExpr { left , op , right } => { let l = to_aexpr ( * left , arena ) ; let r = to_aexpr ( * right , arena ) ; AExpr :: BinaryExpr { left : l , op , right : r , } } Expr :: Not ( e ) => AExpr :: Not ( to_aexpr ( * e , arena ) ) , Expr :: IsNotNull ( e ) => AExpr :: IsNotNull ( to_aexpr ( * e , arena ) ) , Expr :: IsNull ( e ) => AExpr :: IsNull ( to_aexpr ( * e , arena ) ) , Expr :: Cast { expr , data_type } => AExpr :: Cast { expr : to_aexpr ( * expr , arena ) , data_type , } , Expr :: Sort { expr , reverse } => AExpr :: Sort { expr : to_aexpr ( * expr , arena ) , reverse , } , Expr :: AggMin ( expr ) => AExpr :: AggMin ( to_aexpr ( * expr , arena ) ) , Expr :: AggMax ( expr ) => AExpr :: AggMax ( to_aexpr ( * expr , arena ) ) , Expr :: AggMedian ( expr ) => AExpr :: AggMedian ( to_aexpr ( * expr , arena ) ) , Expr :: AggNUnique ( expr ) => AExpr :: AggNUnique ( to_aexpr ( * expr , arena ) ) , Expr :: AggFirst ( expr ) => AExpr :: AggFirst ( to_aexpr ( * expr , arena ) ) , Expr :: AggLast ( expr ) => AExpr :: AggLast ( to_aexpr ( * expr , arena ) ) , Expr :: AggMean ( expr ) => AExpr :: AggMean ( to_aexpr ( * expr , arena ) ) , Expr :: AggList ( expr ) => AExpr :: AggList ( to_aexpr ( * expr , arena ) ) , Expr :: AggCount ( expr ) => AExpr :: AggCount ( to_aexpr ( * expr , arena ) ) , Expr :: AggQuantile { expr , quantile } => AExpr :: AggQuantile { expr : to_aexpr ( * expr , arena ) , quantile , } , Expr :: AggSum ( expr ) => AExpr :: AggSum ( to_aexpr ( * expr , arena ) ) , Expr :: AggGroups ( expr ) => AExpr :: AggGroups ( to_aexpr ( * expr , arena ) ) , Expr :: Ternary { predicate , truthy , falsy , } => { let p = to_aexpr ( * predicate , arena ) ; let t = to_aexpr ( * truthy , arena ) ; let f = to_aexpr ( * falsy , arena ) ; AExpr :: Ternary { predicate : p , truthy : t , falsy : f , } } Expr :: Apply { input , function , output_type , } => AExpr :: Apply { input : to_aexpr ( * input , arena ) , function , output_type , } , Expr :: Shift { input , periods } => AExpr :: Shift { input : to_aexpr ( * input , arena ) , periods , } , Expr :: Wildcard => AExpr :: Wildcard , } ; arena . add ( v ) }
converts expression to AExpr, which uses an arena (Vec) for allocation
converts expression to AExpr which uses an arena ( Vec ) for allocation
expr
Expr
arena
&mut Arena<AExpr>
expr
Expr
arena
&mut Arena<AExpr>