4 ms·
Swift has a really good solution to this, which is an attribute @unknown that you put on the default case, and this attribute produces a warning if there are an
by lilyball 7y ago
Swift has a really good solution to this, which is an attribute @unknown that you put on the default case, and this attribute produces a warning if there are any known enum variants that would match this case. This way you're future-compatible but the warnings tell you when you need to revisit the code. I'm pretty disappointed that Rust didn't copy this.
- Buttons840 7y agoCan't you just do that with a catch all pattern match?
- jeremyjh 7y agoIt’s only relevant if you have a catch-all match. The idea is to get a compiler warning when new patterns become available instead of a runtime warning.
- steveklabnik 7y agoThis is a good idea for a lint!