|
|
|
|
|
by randyrand
2370 days ago
|
|
Using #[non_exhaustive] on enums is going to be general bad practice, just as many in c++ consider ‘default’ switch cases bad practice. When a new state is added to an enum, we want the code to not compile so that we can fix all the places that need updating. |
|
However sometimes you are a dependency and you want to give up this restriction to gain the ability to add things without having to bump your major version number.
By far the most common example is error enums which don't necessarily need all of their downstream crates to handle every error, they likely are bucketing most of them anyway and non_exhaustive ensures they support that.