2 ms·
Or, more precisely, reserves the right to do so in a future version. rustc does not currently do this. There are some compiler flags to randomize the struct lay
by mirashii 2y ago
Or, more precisely, reserves the right to do so in a future version. rustc does not currently do this. There are some compiler flags to randomize the struct layout just to make sure that you’re not implicitly depending on the order.
https://doc.rust-lang.org/reference/type-layout.html https://doc.rust-lang.org/reference/type-layout.html
https://github.com/rust-lang/compiler-team/issues/457 https://github.com/rust-lang/compiler-team/issues/457
- tialaramex 2y ago> Or, more precisely, reserves the right to do so in a future version. rustc does not currently do this Does not currently do what ? Rust certainly will re-arrange the layout of a default repr(Rust) struct to make it smaller, for example: https://rust.godbolt.org/z/7KsqvnE9o https://rust.godbolt.org/z/7KsqvnE9o [Edited to provide a nicer Godbolt example which compares the two layout strategies]
- mirashii 2y agoI stand corrected