polars_utils/
macros.rs

1#[macro_export]
2macro_rules! matches_any_order {
3    ($expression1:expr, $expression2:expr,  $( $pattern1:pat_param )|+,  $( $pattern2:pat_param )|+) => {
4        (matches!($expression1, $( $pattern1 )|+) && matches!($expression2, $( $pattern2)|+)) ||
5        matches!($expression2, $( $pattern1 ) |+) && matches!($expression1, $( $pattern2)|+)
6    }
7}
8
9#[macro_export]
10macro_rules! no_call_const {
11    () => {{
12        const { assert!(false, "should not be called") }
13        unreachable!()
14    }};
15}
16
17// Same as OSS except for the feature gates.
18#[macro_export]
19macro_rules! with_match_physical_numeric_polars_type {(
20    $key_type:expr, | $_:tt $T:ident | $($body:tt)*
21) => ({
22    macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
23    use $crate::datatypes::DataType::*;
24    match $key_type {
25        Int8 => __with_ty__! { Int8Type },
26        Int16 => __with_ty__! { Int16Type },
27        Int32 => __with_ty__! { Int32Type },
28        Int64 => __with_ty__! { Int64Type },
29        Int128 => __with_ty__! { Int128Type },
30        UInt8 => __with_ty__! { UInt8Type },
31        UInt16 => __with_ty__! { UInt16Type },
32        UInt32 => __with_ty__! { UInt32Type },
33        UInt64 => __with_ty__! { UInt64Type },
34        UInt128 => __with_ty__! { UInt128Type },
35        Float32 => __with_ty__! { Float32Type },
36        Float64 => __with_ty__! { Float64Type },
37        dt => panic!("not implemented for dtype {:?}", dt),
38    }
39})}