winput
winput copied to clipboard
Issue 10: support for safe conversion of `u8` into `Vk`
Two functions are added to Vk
: is_valid
, that determines wheter a given u8
value is safe to convert to Vk
enum, and from_u8_safe
that converts an u8
to an Option<Vk>
.
For efficient implementation, a lazily-initialized static array is used (using lazy_static
), with bool
s corresponding to whether a given u8
value (index in the array) is a valid Virtual Key. strum
crate's EnumIter
derive is used to allow iteration over an enum.