vortex_array/arrays/primitive/
native_value.rs1use vortex_dtype::{NativePType, half};
5
6#[repr(transparent)]
12#[derive(Copy, Clone, Debug)]
13pub struct NativeValue<T>(pub T);
14
15impl<T: NativePType> PartialEq<NativeValue<T>> for NativeValue<T> {
16 fn eq(&self, other: &NativeValue<T>) -> bool {
17 self.0.is_eq(other.0)
18 }
19}
20
21impl<T: NativePType> Eq for NativeValue<T> {}
22
23macro_rules! prim_value {
24 ($typ:ty) => {
25 impl core::hash::Hash for NativeValue<$typ> {
26 fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
27 self.0.hash(state);
28 }
29 }
30 };
31}
32
33macro_rules! float_value {
34 ($typ:ty) => {
35 impl core::hash::Hash for NativeValue<$typ> {
36 fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
37 self.0.to_bits().hash(state);
38 }
39 }
40 };
41}
42
43prim_value!(u8);
44prim_value!(u16);
45prim_value!(u32);
46prim_value!(u64);
47prim_value!(i8);
48prim_value!(i16);
49prim_value!(i32);
50prim_value!(i64);
51float_value!(half::f16);
52float_value!(f32);
53float_value!(f64);