WIP
WIP WIP: keymap generation test passes meta: Update features and version WiP: cargo.lock WIP: don't crash WIP: no outlines parsing: New tests WIP: base level works WIP: remove old keyboard symbols correctly input WIP: lodaing files WIP: fallback works Valid fallback
This commit is contained in:
22
src/resources.rs
Normal file
22
src/resources.rs
Normal file
@ -0,0 +1,22 @@
|
||||
/*! Statically linked resources.
|
||||
* This could be done using GResource, but that would need additional work.
|
||||
*/
|
||||
|
||||
|
||||
const KEYBOARDS: &[(*const str, *const str)] = &[
|
||||
("us", include_str!("../data/keyboards/us.yaml"))
|
||||
];
|
||||
|
||||
pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
||||
// Need to dereference in unsafe code
|
||||
// comparing *const str to &str will compare pointers
|
||||
KEYBOARDS.iter()
|
||||
.find(|(name, _)| {
|
||||
let name: *const str = *name;
|
||||
(unsafe { &*name }) == needle
|
||||
})
|
||||
.map(|(_, value)| {
|
||||
let value: *const str = *value;
|
||||
unsafe { &*value }
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user