Sfoglia il codice sorgente

aya: implement Pod for arrays of Pod types

If a type is POD (meaning it can be converted to a byte array), then an
array of such type is POD.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
Tuetuopay 3 anni fa
parent
commit
08211f6
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      aya/src/bpf.rs

+ 3 - 0
aya/src/bpf.rs

@@ -54,6 +54,9 @@ macro_rules! unsafe_impl_pod {
 
 unsafe_impl_pod!(i8, u8, i16, u16, i32, u32, i64, u64, u128, i128);
 
+// It only makes sense that an array of POD types is itself POD
+unsafe impl<T: Pod, const N: usize> Pod for [T; N] {}
+
 #[allow(non_camel_case_types)]
 #[repr(C)]
 #[derive(Copy, Clone, Debug, Default, PartialEq)]