summaryrefslogtreecommitdiffstats
path: root/src/config/keymap.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:13 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:25 -0500
commit0be734a6d7154573d8e570980f0af27ac5cb8190 (patch)
tree76789bee4f068ba000a13921ae5caec0a8c4cabe /src/config/keymap.rs
parent348ef3c36115ac7060f141c27157b6b2f5c91f37 (diff)
rust 2018 and clippy
Diffstat (limited to 'src/config/keymap.rs')
-rw-r--r--src/config/keymap.rs43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/config/keymap.rs b/src/config/keymap.rs
index 83e48e4..eb0c81c 100644
--- a/src/config/keymap.rs
+++ b/src/config/keymap.rs
@@ -1,13 +1,10 @@
-extern crate fs_extra;
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
use std::process::exit;
-use commands;
-use config::{parse_config_file, Flattenable};
-use KEYMAP_FILE;
+use crate::commands;
+use crate::config::{parse_config_file, Flattenable};
+use crate::KEYMAP_FILE;
pub const BACKSPACE: i32 = 0x7F;
pub const TAB: i32 = 0x9;
@@ -73,25 +70,23 @@ fn insert_keycommand(
if let Some(s) = key_to_i32(&keys[0]) {
map.insert(s, commands::CommandKeybind::SimpleKeybind(keycommand));
}
- } else {
- if let Some(s) = key_to_i32(&keys[0]) {
- let mut new_map: HashMap<i32, commands::CommandKeybind>;
- match map.remove(&s) {
- Some(commands::CommandKeybind::CompositeKeybind(mut m)) => {
- new_map = m;
- }
- Some(_) => {
- eprintln!("Error: Keybindings ambiguous");
- exit(1);
- }
- None => {
- new_map = HashMap::new();
- }
+ } else if let Some(s) = key_to_i32(&keys[0]) {
+ let mut new_map: HashMap<i32, commands::CommandKeybind>;
+ match map.remove(&s) {
+ Some(commands::CommandKeybind::CompositeKeybind(m)) => {
+ new_map = m;
+ }
+ Some(_) => {
+ eprintln!("Error: Keybindings ambiguous");
+ exit(1);
+ }
+ None => {
+ new_map = HashMap::new();
}
- insert_keycommand(&mut new_map, keycommand, &keys[1..]);
- let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
- map.insert(s as i32, composite_command);
}
+ insert_keycommand(&mut new_map, keycommand, &keys[1..]);
+ let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
+ map.insert(s as i32, composite_command);
}
}