alamb commented on a change in pull request #9597: URL: https://github.com/apache/arrow/pull/9597#discussion_r593734761
########## File path: rust/arrow/src/alloc/types.rs ########## @@ -35,141 +35,37 @@ pub unsafe trait NativeType: fn to_le_bytes(&self) -> Self::Bytes; } -unsafe impl NativeType for u8 { - type Bytes = [u8; std::mem::size_of::<Self>()]; - #[inline] - fn to_le_bytes(&self) -> Self::Bytes { - Self::to_le_bytes(*self) - } - - #[inline] - fn is_valid(data_type: &DataType) -> bool { - data_type == &DataType::UInt8 - } -} - -unsafe impl NativeType for u16 { - type Bytes = [u8; std::mem::size_of::<Self>()]; - #[inline] - fn to_le_bytes(&self) -> Self::Bytes { - Self::to_le_bytes(*self) - } - - #[inline] - fn is_valid(data_type: &DataType) -> bool { - data_type == &DataType::UInt16 - } -} - -unsafe impl NativeType for u32 { - type Bytes = [u8; std::mem::size_of::<Self>()]; - #[inline] - fn to_le_bytes(&self) -> Self::Bytes { - Self::to_le_bytes(*self) - } - - #[inline] - fn is_valid(data_type: &DataType) -> bool { - data_type == &DataType::UInt32 - } +macro_rules! create_native { + ($native_ty:ty,$($impl_pattern:pat)|+) => { Review comment: Today I learned about `:pat`! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org