+Here the `Bar` enum is guaranteed to have the same layout as `u8`. In addition, the `Bar::C` variant is guaranteed to have a discriminant of 42. Variants without explicitly-specified values will have discriminants that are automatically assigned according to their order in the source code, so `Bar::A` will have a discriminant of 0, `Bar::B` will have a discriminant of 1, and `Bar::D` will have a discriminant of 43. Without this feature, the only way to set the explicit value of `Bar::C` would be to add 41 unnecessary variants before it!
0 commit comments