Skip to content

Commit 20b55b7

Browse files
committed
Clarify semantics of #[repr(align(x))] on enums
1 parent 73bf070 commit 20b55b7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/doc/unstable-book/src/language-features/repr-align-enum.md

+16
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ fn main() {
2424
assert_eq!(std::mem::align_of::<Aligned>(), 8);
2525
}
2626
```
27+
28+
This is equivalent to using an aligned wrapper struct everywhere:
29+
30+
```rust
31+
#[repr(align(8))]
32+
struct Aligned(Unaligned);
33+
34+
enum Unaligned {
35+
Foo,
36+
Bar { value: u32 },
37+
}
38+
39+
fn main() {
40+
assert_eq!(std::mem::align_of::<Aligned>(), 8);
41+
}
42+
```

0 commit comments

Comments
 (0)