polars_plan/dsl/functions/
arity.rs1use super::*;
2
3macro_rules! prepare_binary_function {
4 ($f:ident) => {
5 move |c: &mut [Column]| {
6 let s0 = std::mem::take(&mut c[0]);
7 let s1 = std::mem::take(&mut c[1]);
8
9 $f(s0, s1)
10 }
11 };
12}
13
14pub fn map_binary<F>(a: Expr, b: Expr, f: F, output_type: GetOutput) -> Expr
18where
19 F: 'static + Fn(Column, Column) -> PolarsResult<Option<Column>> + Send + Sync,
20{
21 let function = prepare_binary_function!(f);
22 a.map_many(function, &[b], output_type)
23}
24
25pub fn apply_binary<F>(a: Expr, b: Expr, f: F, output_type: GetOutput) -> Expr
29where
30 F: 'static + Fn(Column, Column) -> PolarsResult<Option<Column>> + Send + Sync,
31{
32 let function = prepare_binary_function!(f);
33 a.apply_many(function, &[b], output_type)
34}