[Pre-RFC] Inferred Enum Type

To me, the awkward thing about adding this is that it could easily lead to needing to change the conventions for how variants are named.

Something like make_webrequest(CookieHandling::Skip) is perfectly readable, but make_webrequest(_::Skip) is pretty confusing. So because the latter syntax doesn't exist, a variant name of Skip is reasonable today, but might not be good later.

But if people end up wanting to do _::SkipCookies, that's the kind of repetitive naming (CookieHandling::SkipCookies) that having scoped enums is supposed to avoid in the first place.

That said, there are some contexts where something else helps make it clear. Like if it was RequestOptions { cookie_handling: _::Skip, .. }, that seems completely fine, and less annoying than today's RequestOptions { cookie_handling: CookieHandling::Skip, .. }.

I don't know, though, whether trying to enforce such things in the grammar would be good. Maybe there's some nice simple rules that could be errors if not followed. Maybe it should be left up to conventions, with clippy lints to push people towards best practices. I'd definitely like to see some starting point proposals in both directions to compare and maybe mix together.

22 Likes