polars_arrow/util/
macros.rs

1#[macro_export]
2macro_rules! with_match_primitive_type {(
3    $key_type:expr, | $_:tt $T:ident | $($body:tt)*
4) => ({
5    macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
6    use $crate::datatypes::PrimitiveType::*;
7    match $key_type {
8        Int8 => __with_ty__! { i8 },
9        Int16 => __with_ty__! { i16 },
10        Int32 => __with_ty__! { i32 },
11        Int64 => __with_ty__! { i64 },
12        Int128 => __with_ty__! { i128 },
13        UInt8 => __with_ty__! { u8 },
14        UInt16 => __with_ty__! { u16 },
15        UInt32 => __with_ty__! { u32 },
16        UInt64 => __with_ty__! { u64 },
17        UInt128 => __with_ty__! { u128 },
18        Float32 => __with_ty__! { f32 },
19        Float64 => __with_ty__! { f64 },
20        _ => panic!("operator does not support primitive `{:?}`",
21            $key_type)
22    }
23})}
24
25#[macro_export]
26macro_rules! with_match_primitive_type_full {(
27    $key_type:expr, | $_:tt $T:ident | $($body:tt)*
28) => ({
29    macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
30    use $crate::datatypes::PrimitiveType::*;
31    use $crate::types::{f16};
32    match $key_type {
33        Int8 => __with_ty__! { i8 },
34        Int16 => __with_ty__! { i16 },
35        Int32 => __with_ty__! { i32 },
36        Int64 => __with_ty__! { i64 },
37        Int128 => __with_ty__! { i128 },
38        UInt8 => __with_ty__! { u8 },
39        UInt16 => __with_ty__! { u16 },
40        UInt32 => __with_ty__! { u32 },
41        UInt64 => __with_ty__! { u64 },
42        UInt128 => __with_ty__! { u128 },
43        Float16 => __with_ty__! { f16 },
44        Float32 => __with_ty__! { f32 },
45        Float64 => __with_ty__! { f64 },
46        _ => panic!("operator does not support primitive `{:?}`",
47            $key_type)
48    }
49})}
50
51#[macro_export]
52macro_rules! match_integer_type {(
53    $key_type:expr, | $_:tt $T:ident | $($body:tt)*
54) => ({
55    macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
56    use $crate::datatypes::IntegerType::*;
57    match $key_type {
58        Int8 => __with_ty__! { i8 },
59        Int16 => __with_ty__! { i16 },
60        Int32 => __with_ty__! { i32 },
61        Int64 => __with_ty__! { i64 },
62        Int128 => __with_ty__! { i128 },
63        UInt8 => __with_ty__! { u8 },
64        UInt16 => __with_ty__! { u16 },
65        UInt32 => __with_ty__! { u32 },
66        UInt64 => __with_ty__! { u64 },
67        UInt128 => __with_ty__! { u128 },
68    }
69})}