In rust, if a crate publishes an enum, then adding variant to the enum is a breaking change. Because if the dependent crate does a match against value of that enum type, and that match does not have a default (
_) branch, because it covers all existing variants, then the match will break by extending the enum.
So what should a crate do to leave itself the option to extend the enum later?
The above is the only case I could think of, but there may be others. Is there perhaps some way to put a private dummy value in the enum that can’t be matched explicitly, thus forcing a default branch in each match? If there isn’t, should it be proposed?
If all the variants have the same parameters, a tuple(struct) with integeral tag can probably be used instead. But if the parameters are not regular…