replace uarray with Pod
This commit is contained in:
20
sub/core/src/pod.rs
Normal file
20
sub/core/src/pod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
/// Plain Old data type
|
||||
pub trait Pod: Copy + 'static {
|
||||
fn uninit() -> Self { unsafe { MaybeUninit::uninit().assume_init() } }
|
||||
fn zeroed() -> Self { unsafe { MaybeUninit::zeroed().assume_init() } }
|
||||
}
|
||||
|
||||
macro_rules! primitive {
|
||||
($($p:ty),*) => {
|
||||
$(impl Pod for $p {})*
|
||||
}
|
||||
}
|
||||
|
||||
primitive!(u8, u16, u32, u64, u128);
|
||||
primitive!(i8, i16, i32, i64, i128);
|
||||
primitive!(f32, f64, usize, isize);
|
||||
primitive!(());
|
||||
|
||||
impl<const LEN: usize, T: Pod> Pod for [T;LEN] {}
|
||||
Reference in New Issue
Block a user