This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/SaltyMaybe7887 on 2025-05-27 08:05:05+00:00.


struct Inner {
 a: u32,
 b: u8,
}

struct Outer {
 c: u16,
 inner: Inner,
 d: u8,
}

Is the Rust compiler allowed to make the outer struct have the following memory layout?

struct Outer { a: u32, c: u16, b: u8, d: u8, }

If it isn’t, why?