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