I was just wondering if there's currently a KEEP f...
# language-proposals
s
I was just wondering if there's currently a KEEP for adding support for non-exhaustive enums. I recently discovered this in Rust and I think it's really useful for enum classes that aren't finished yet and more enums will follow (a good example might be error codes). I'm imagining an annotation
@NonExhaustive
which forces you to define an
else
branch even if you cover all enums in your when clause. See Rust docs: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute Here's their original RFC from 2008: https://github.com/rust-lang/rfcs/blob/master/text/2008-non-exhaustive.md
s
That's exactly what I was looking for. Thanks ­čÖé
­čĹŹ 2
o
I don't see why you wouldn't want error code enums to be exhaustive
d
In a very large code base, it's a big / potentially infeasible burden to need to update all users of your enum when you add a new value. The protocol buffer compiler emits a dummy "do not make exhaustive switches for proto enum" value to support easy enum evolution.