Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Until 2012, Rust 0.6 required a postfix `.` on enum variants:

https://github.com/rust-lang/rust/commit/04a2887f879

And here's a 2013 bug for the ambiguity:

https://github.com/rust-lang/rust/issues/10402



I was just about to comment that it's unfortunate that languages seem to have settled on the (false) dichotomy that enum variants should be either `MyEnumName.variantname` or just plain `variantname`. Often, you want enum variants to read almost like inbuilt literals, as that leads to more readable "natural-sounding" code than needing to say `MyEnumName.variantname` every time. However, having them actually be bareword literals leads to both ambiguity while reading and to long term maintainability issue like the one in the post. Postfix `.` may or may not be a great syntax specifically, but something like it still seems like a great compromise between these two extremes.

Do you know why the syntax was decided to get axed? Is this part of a larger PR where the decision is elaborated upon?




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: