2 ms·
Generating new structs is free in Rust. There is only cost if you need to send it somewhere and the layout differs from the original. Since `transmute` will be
by kevincox 6y ago
Generating new structs is free in Rust. There is only cost if you need to send it somewhere and the layout differs from the original.
Since `transmute` will be undefined behaviour if the layout differs you will only be saving cost if you would be invoking undefined behaviour.
I recommend checking the generated asm and reporting a missed-optimization bug if it differs.