Key was defined as an enum with three variants and a from_u8 method (that should have been named from_u32) that transmuted a u32 to a Key:
#[repr(u32)]
pub enum Key {
Unknown = 0,
A = 2335202,
Enter = 67114680,
}
That caused UB when the value was not one of 0, 2335202 or 67114680. This PR changes Key to a wrapper struct around a u32, with the variants becoming associated constants. from_u32 is replaced with a From<u32> implementation.
Key
was defined as an enum with three variants and afrom_u8
method (that should have been namedfrom_u32
) that transmuted au32
to aKey
:That caused UB when the value was not one of 0, 2335202 or 67114680. This PR changes
Key
to a wrapper struct around au32
, with the variants becoming associated constants.from_u32
is replaced with aFrom<u32>
implementation.