You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that some enums seem to not be stored as compactly as they could be considering they should equate to unions. The two enums below, Foo and Bar, consist of two variants each. Each variant is <= 8 bytes, so the total size should fit within (8+tag) bytes, and they should take up the same space as each other. It seems however that the data is being stored adjacently rather than overlapping, as Foo takes up 16 bytes and Bar takes up 12 bytes. Is this a bug or is there an alternative way to obtain more compact data structures? (I suppose I could manually tag a struct and use transmute if necessary.)
I believe the tag is stored first, followed by padding such that the i64 or i32 is aligned to 4 Bytes, which is why the tag seems to take up 8/4 Bytes.
I noticed that some enums seem to not be stored as compactly as they could be considering they should equate to unions. The two enums below,
Foo
andBar
, consist of two variants each. Each variant is <= 8 bytes, so the total size should fit within (8+tag) bytes, and they should take up the same space as each other. It seems however that the data is being stored adjacently rather than overlapping, asFoo
takes up 16 bytes andBar
takes up 12 bytes. Is this a bug or is there an alternative way to obtain more compact data structures? (I suppose I could manually tag a struct and usetransmute
if necessary.)The text was updated successfully, but these errors were encountered: