Macro arrow_array::downcast_temporal
source ยท macro_rules! downcast_temporal { ($($data_type:expr),+ => ($m:path $(, $args:tt)*), $($p:pat => $fallback:expr $(,)*)*) => { ... }; }
Expand description
Given one or more expressions evaluating to primitive DataType
invokes the provided macro
m
with the corresponding ArrowPrimitiveType
, followed by any additional arguments
macro_rules! temporal_size_helper {
($t:ty, $o:ty) => {
std::mem::size_of::<<$t as ArrowPrimitiveType>::Native>() as $o
};
}
fn temporal_size(t: &DataType) -> u8 {
downcast_temporal! {
t => (temporal_size_helper, u8),
_ => u8::MAX
}
}
assert_eq!(temporal_size(&DataType::Date32), 4);
assert_eq!(temporal_size(&DataType::Date64), 8);