Re:Abstraction without overhead: traits in Rust
by kibwen on Monday May 11, 2015 @06:10PM
(#9528186)
This is incorrect. The following Rust enum compiles down to a single byte, whose variants are represented by the numbers 0, 1, and 2:
You can even give them all numeric values explicitly:
And you can also just tell it where to start and let it count from there:
If you throw the #[repr(C)] attribute on any of these then Rust will make sure to size them as C would on your particular platform (on my machine this attribute inflates them from 8 bits to 64 bits), making them usable directly from C as well.
[ Parent
| on HN ]
There are no comments on this comment yet.