As I was reading the blog for Rust stable 1.20, I saw the associated constants and wondered how it would work for enums. Sadly in order to have a different constant for each variation of an enum they must be treated as types, which was brought up by https://github.com/rust-lang/rfcs/pull/1450 which was postponed.
So, I feel that it has been a decent amount of time since the postponing, and it was said that it would be revisited. So I just wanted to bring it up here for revisit. I’m not sure if there are any specific things blocking this as of now.
It’s also possible that it could be approached from the other direction, making enums out of nominal types directly. (Along the lines of the IpAddr enum.) If that got automatic .into() impls it might avoid the “is the the variant or is it the enum” typing problems. I could imagine a form of that that would be incredibly useful for error types.
I’ve seen the IpAddr enum style used a lot and I myself use it aswell. It’s a decent work around, it just doesn’t look that nice when you have longer names.