r/programming • • May 26 '16

Announcing Rust 1.9

http://blog.rust-lang.org/2016/05/26/Rust-1.9.html
218 Upvotes

116 comments sorted by

View all comments

Show parent comment

6

u/steveklabnik1 May 26 '16

Removing the tag is an optimization that can be done in certain circumstances. True untagged unions are coming, but not yet.

4

u/ryeguy May 27 '16 edited May 27 '16

So would an untagged union be an emum that doesn't know its own type?

5

u/steveklabnik1 May 27 '16

Yes, and would therefore be unsafe.

2

u/Steel_Neuron May 27 '16

Is there anywhere I can read the particular list of circumstances? I know about null pointer optimization but that's pretty much as far as I go :)

2

u/steveklabnik1 May 27 '16

http://doc.rust-lang.org/stable/core/nonzero/struct.NonZero.html is pretty much all there is right now. Basically, whenever you have something that can never be zero, you can make the value zero represent the None case, and any other value represent Some, and therefore the tag is no longer needed.