Closed as not planned
Description
struct S {
a: u32,
b: i128,
}
enum Foo {
Var1(S),
Var2(S),
}
use std::mem::size_of;
dbg!(size_of::<S>());
dbg!(size_of::<Foo>());
this code prints
[src/main.rs:13] size_of::<S>() = 24
[src/main.rs:14] size_of::<Foo>() = 32
when it could have instead used the free padding bytes in S
for the discriminant, so Foo
would be the same size as S
Metadata
Metadata
Assignees
Labels
No labels