constructors for aligned

This commit is contained in:
Intege-rs
2025-03-13 15:49:29 -04:00
parent 362d44c712
commit bb2fd32d27

View File

@@ -2,6 +2,16 @@
pub struct Align<const ALIGNMENT: usize>( <Self as Aligned>::Alignment ) where Self: Aligned;
pub trait Aligned { type Alignment; }
impl <const ALIGNMENT: usize> Align<ALIGNMENT> where Self: Aligned {
const fn new() -> Self { unsafe { core::mem::zeroed() } }
}
unsafe impl <const ALIGNMENT: usize> crate::data::Zeroed for Align<ALIGNMENT> where Self: Aligned {}
impl <const ALIGNMENT: usize> Default for Align<ALIGNMENT> where Self: Aligned {
fn default() -> Self { Self::new() }
}
macro_rules! gen_alignment {
($($alignment:literal),+) => {
$(