logoalt Hacker News

porisetoday at 6:50 AM2 repliesview on HN

Why is rust allowed to reorder fields? If I know that fields are going to be generally accessed together, this prevents me from ordering them so they fit in cache lines.


Replies

kzrdudetoday at 7:13 AM

It's allowed as an optimization, the order it uses will limit the space lost to field alignment.

Narishmatoday at 7:09 AM

You can tell it not to reorder them if you want but it's not the default.