polars_plan/dsl/functions/
arity.rsuse super::*;
macro_rules! prepare_binary_function {
($f:ident) => {
move |c: &mut [Column]| {
let s0 = std::mem::take(&mut c[0]);
let s1 = std::mem::take(&mut c[1]);
$f(s0, s1)
}
};
}
pub fn map_binary<F>(a: Expr, b: Expr, f: F, output_type: GetOutput) -> Expr
where
F: 'static + Fn(Column, Column) -> PolarsResult<Option<Column>> + Send + Sync,
{
let function = prepare_binary_function!(f);
a.map_many(function, &[b], output_type)
}
pub fn apply_binary<F>(a: Expr, b: Expr, f: F, output_type: GetOutput) -> Expr
where
F: 'static + Fn(Column, Column) -> PolarsResult<Option<Column>> + Send + Sync,
{
let function = prepare_binary_function!(f);
a.apply_many(function, &[b], output_type)
}