Hello!
I know that Rust can, if it want to, reorder attributes in a struct.
I know this can help if padding can be optimized out or limited but what is the rules applied by the compiler to do this?
Can I be sure that for example this structure is not reordered and can be considered to have the same memory layout has an slice of 4 float32 with x, y, z and w in the same order?
Ok thank you, I was aware of the repr(C) attributes but I will be really surprise that Rust reorder struct without padding like Vec4, that will completely break possible SIMD generation.
(The above is just the minimal implementation of the idea, realistic code will probably want to use a newtype of array in order to be able to add methods and such.)
To be clear, I'm not saying that Rust will ever do this! The compiler developers just don't want to rule it out prematurely, as the language's stability guarentees would make it difficult for them to reverse that decision at a later date.