Overflow warning when working with primitive enums

Provided this playground example: Rust Playground

I expected the compiler to emit 2 overflow warnings, one for the manual coercion and one for the enum invariant coercion.
Is there a way to make the compiler realise there is an overflow happening when coercing enum values?

Maybe put #[repr(u8)] on top of the enum.

1 Like