pub unsafe trait Alignment: Sealed { }Expand description
Implemented for all Align<N> where N is a
valid alignment (i.e., a power of two less-than-or-equal to
228).
use elain::{Align, Alignment};
use core::mem::align_of;
#[repr(C)]
struct Foo<const MIN_ALIGNMENT: usize>
where
Align<MIN_ALIGNMENT>: Alignment
{
_align: Align<MIN_ALIGNMENT>,
bar: u8,
baz: u16,
}
assert_eq!(align_of::<Foo<1>>(), 2);
assert_eq!(align_of::<Foo<2>>(), 2);
assert_eq!(align_of::<Foo<4>>(), 4);