aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/config.rs b/src/config.rs
index be967150..eb7f0f72 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -214,7 +214,7 @@ impl<'a> Shell<'a> {
{
Shell {
program: program.into(),
- args: args
+ args,
}
}
@@ -678,9 +678,9 @@ struct RawBinding {
impl RawBinding {
fn into_mouse_binding(self) -> ::std::result::Result<MouseBinding, Self> {
- if self.mouse.is_some() {
+ if let Some(mouse) = self.mouse {
Ok(Binding {
- trigger: self.mouse.unwrap(),
+ trigger: mouse,
mods: self.mods,
action: self.action,
mode: self.mode,
@@ -692,9 +692,9 @@ impl RawBinding {
}
fn into_key_binding(self) -> ::std::result::Result<KeyBinding, Self> {
- if self.key.is_some() {
+ if let Some(key) = self.key {
Ok(KeyBinding {
- trigger: self.key.unwrap(),
+ trigger: key,
mods: self.mods,
action: self.action,
mode: self.mode,
@@ -865,12 +865,12 @@ impl<'a> de::Deserialize<'a> for RawBinding {
}
Ok(RawBinding {
- mode: mode,
+ mode,
notmode: not_mode,
- action: action,
- key: key,
- mouse: mouse,
- mods: mods,
+ action,
+ key,
+ mouse,
+ mods,
})
}
}
@@ -977,8 +977,8 @@ impl CursorOrPrimaryColors {
fn into_cursor_colors(self) -> CursorColors {
match self {
CursorOrPrimaryColors::Cursor { text, cursor } => CursorColors {
- text: text,
- cursor: cursor
+ text,
+ cursor,
},
CursorOrPrimaryColors::Primary { foreground, background } => {
// Must print in config since logger isn't setup yet.
@@ -1124,12 +1124,12 @@ impl FromStr for Rgb {
macro_rules! component {
($($c:ident),*) => {
$(
- match chars.next().unwrap().to_digit(16) {
+ match chars.next().and_then(|c| c.to_digit(16)) {
Some(val) => rgb.$c = (val as u8) << 4,
None => return Err(())
}
- match chars.next().unwrap().to_digit(16) {
+ match chars.next().and_then(|c| c.to_digit(16)) {
Some(val) => rgb.$c |= val as u8,
None => return Err(())
}
@@ -1137,9 +1137,9 @@ impl FromStr for Rgb {
}
}
- match chars.next().unwrap() {
- '0' => if chars.next().unwrap() != 'x' { return Err(()); },
- '#' => (),
+ match chars.next() {
+ Some('0') => if chars.next() != Some('x') { return Err(()); },
+ Some('#') => (),
_ => return Err(()),
}
@@ -1429,8 +1429,8 @@ impl Default for Dimensions {
impl Dimensions {
pub fn new(columns: Column, lines: Line) -> Self {
Dimensions {
- columns: columns,
- lines: lines
+ columns,
+ lines,
}
}
@@ -1668,7 +1668,8 @@ impl Monitor {
_thread: ::util::thread::spawn_named("config watcher", move || {
let (tx, rx) = mpsc::channel();
// The Duration argument is a debouncing period.
- let mut watcher = watcher(tx, Duration::from_millis(10)).unwrap();
+ let mut watcher = watcher(tx, Duration::from_millis(10))
+ .expect("Unable to spawn file watcher");
let config_path = ::std::fs::canonicalize(path)
.expect("canonicalize config path");
@@ -1742,7 +1743,6 @@ enum Key {
Key8,
Key9,
Key0,
-
A,
B,
C,
@@ -1769,9 +1769,7 @@ enum Key {
X,
Y,
Z,
-
Escape,
-
F1,
F2,
F3,
@@ -1787,7 +1785,6 @@ enum Key {
F13,
F14,
F15,
-
Snapshot,
Scroll,
Pause,
@@ -1797,7 +1794,6 @@ enum Key {
End,
PageDown,
PageUp,
-
Left,
Up,
Right,
@@ -1817,7 +1813,6 @@ enum Key {
Numpad7,
Numpad8,
Numpad9,
-
AbntC1,
AbntC2,
Add,