Remove unsafe call in input mapper (#222)
* Remove unsafe call * Run cargo fmt Co-authored-by: RustyNixieTube <RustyNixieTube@users.noreply.github.com>
This commit is contained in:
parent
cced057459
commit
affc9cc320
|
|
@ -21,7 +21,7 @@ struct MappingEntry {
|
||||||
action: Message,
|
action: Message,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone)]
|
||||||
struct KeyMappingEntries(Vec<MappingEntry>);
|
struct KeyMappingEntries(Vec<MappingEntry>);
|
||||||
|
|
||||||
impl KeyMappingEntries {
|
impl KeyMappingEntries {
|
||||||
|
|
@ -38,12 +38,19 @@ impl KeyMappingEntries {
|
||||||
self.0.push(entry)
|
self.0.push(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn new() -> Self {
|
||||||
|
Self(Vec::new())
|
||||||
|
}
|
||||||
|
|
||||||
fn key_array() -> [Self; NUMBER_OF_KEYS] {
|
fn key_array() -> [Self; NUMBER_OF_KEYS] {
|
||||||
let mut array: [KeyMappingEntries; NUMBER_OF_KEYS] = unsafe { std::mem::zeroed() };
|
const DEFAULT: KeyMappingEntries = KeyMappingEntries::new();
|
||||||
for key in array.iter_mut() {
|
[DEFAULT; NUMBER_OF_KEYS]
|
||||||
*key = KeyMappingEntries::default();
|
}
|
||||||
}
|
}
|
||||||
array
|
|
||||||
|
impl Default for KeyMappingEntries {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue