Skip to content

Commit 1339a1d

Browse files
committed
refactor(key_config.rs): remove the redundant checks
1 parent 524a92a commit 1339a1d

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/keys/key_config.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, Result};
1+
use anyhow::Result;
22
use crossterm::event::{KeyCode, KeyModifiers};
33
use std::{fs::canonicalize, path::PathBuf, rc::Rc};
44

@@ -38,27 +38,16 @@ impl KeyConfig {
3838
key_bindings_path: Option<&PathBuf>,
3939
key_symbols_path: Option<&PathBuf>,
4040
) -> Result<Self> {
41-
let keys = if let Some(path) = key_bindings_path {
42-
if !path.exists() {
43-
return Err(anyhow!(
44-
"The custom key bindings file dosen't exists"
45-
));
46-
}
47-
KeysList::init(path.clone())
48-
} else {
49-
KeysList::init(Self::get_config_file()?)
50-
};
51-
52-
let symbols = if let Some(path) = key_symbols_path {
53-
if !path.exists() {
54-
return Err(anyhow!(
55-
"The custom key symbols file dosen't exists"
56-
));
57-
}
58-
KeySymbols::init(path.clone())
59-
} else {
60-
KeySymbols::init(Self::get_symbols_file()?)
61-
};
41+
let keys = KeysList::init(
42+
key_bindings_path
43+
.unwrap_or(&Self::get_config_file()?)
44+
.clone(),
45+
);
46+
let symbols = KeySymbols::init(
47+
key_symbols_path
48+
.unwrap_or(&Self::get_symbols_file()?)
49+
.clone(),
50+
);
6251

6352
Ok(Self { keys, symbols })
6453
}

0 commit comments

Comments
 (0)