Set the minimum alignments of types using const generics, rather
than #[repr(align(N))]
.
The type Align<N>
is a zero-sized-type with alignment
equal to N
:
```rust
use elain::Align;
use core::mem::{alignof, alignof_val};
asserteq!(alignof::
const FOO_ALIGN: usize = 8;
struct Foo {
_align: Align
let foo: Foo = Foo { _align: Align::new() };
asserteq!(alignof_val(&foo), 8); ```
Valid alignments are powers of two less-than-or-equal to 228.
Supplying an invalid alignment to [Align
] is a type error:
```rust
use elain::Align;
struct Foo(Align<3>); // Compile Error ```
Because only some integers are valid alignments, supplying the alignment of a type generically requires some extra work: ```rust use elain::Align;
struct Foo
To resolve this error, add a
wherebound like so, using the
[
Alignment] trait to check that
Align
```rust use elain::{Align, Alignment}; use core::mem::align_of;
struct Foo
asserteq!(alignof::