Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-arrow/src/util/macros.rs
8424 views
1
#[macro_export]
2
macro_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 polars_utils::float16::pf16;
7
use $crate::datatypes::PrimitiveType::*;
8
9
match $key_type {
10
Int8 => __with_ty__! { i8 },
11
Int16 => __with_ty__! { i16 },
12
Int32 => __with_ty__! { i32 },
13
Int64 => __with_ty__! { i64 },
14
Int128 => __with_ty__! { i128 },
15
UInt8 => __with_ty__! { u8 },
16
UInt16 => __with_ty__! { u16 },
17
UInt32 => __with_ty__! { u32 },
18
UInt64 => __with_ty__! { u64 },
19
UInt128 => __with_ty__! { u128 },
20
Float16 => __with_ty__! { pf16 },
21
Float32 => __with_ty__! { f32 },
22
Float64 => __with_ty__! { f64 },
23
_ => panic!("operator does not support primitive `{:?}`",
24
$key_type)
25
}
26
})}
27
28
#[macro_export]
29
macro_rules! with_match_primitive_type_full {(
30
$key_type:expr, | $_:tt $T:ident | $($body:tt)*
31
) => ({
32
macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
33
use polars_utils::float16::pf16;
34
use $crate::datatypes::PrimitiveType::*;
35
36
match $key_type {
37
Int8 => __with_ty__! { i8 },
38
Int16 => __with_ty__! { i16 },
39
Int32 => __with_ty__! { i32 },
40
Int64 => __with_ty__! { i64 },
41
Int128 => __with_ty__! { i128 },
42
UInt8 => __with_ty__! { u8 },
43
UInt16 => __with_ty__! { u16 },
44
UInt32 => __with_ty__! { u32 },
45
UInt64 => __with_ty__! { u64 },
46
UInt128 => __with_ty__! { u128 },
47
Float16 => __with_ty__! { pf16 },
48
Float32 => __with_ty__! { f32 },
49
Float64 => __with_ty__! { f64 },
50
_ => panic!("operator does not support primitive `{:?}`",
51
$key_type)
52
}
53
})}
54
55
#[macro_export]
56
macro_rules! match_integer_type {(
57
$key_type:expr, | $_:tt $T:ident | $($body:tt)*
58
) => ({
59
macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}
60
use $crate::datatypes::IntegerType::*;
61
match $key_type {
62
Int8 => __with_ty__! { i8 },
63
Int16 => __with_ty__! { i16 },
64
Int32 => __with_ty__! { i32 },
65
Int64 => __with_ty__! { i64 },
66
Int128 => __with_ty__! { i128 },
67
UInt8 => __with_ty__! { u8 },
68
UInt16 => __with_ty__! { u16 },
69
UInt32 => __with_ty__! { u32 },
70
UInt64 => __with_ty__! { u64 },
71
UInt128 => __with_ty__! { u128 },
72
}
73
})}
74
75