summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarawit Rakket <narawitrakket@hotmail.com>2022-07-12 09:07:05 +0700
committerAbin Simon <abinsimon10@gmail.com>2022-07-13 18:57:18 +0530
commit55c2ef1a7b318b2cd4b6f7aef9e8c1af06a052c0 (patch)
tree295fc7df6e1805c3aa27750ab538247e290c91fa
parent6370bdeaff9bb1dd49430468ab22d49658cc7d44 (diff)
refactor: simplify control flow
-rw-r--r--src/config_file.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/config_file.rs b/src/config_file.rs
index 0c611a6..642eb38 100644
--- a/src/config_file.rs
+++ b/src/config_file.rs
@@ -132,22 +132,19 @@ impl Config {
pub fn config_file_path() -> Option<PathBuf> {
use xdg::BaseDirectories;
match BaseDirectories::with_prefix(CONF_DIR) {
- Ok(p) => {
- return Some(p.get_config_home());
+ Ok(p) => Some(p.get_config_home()),
+ Err(e) => {
+ print_error!("Can not open config file: {}.", e);
+ None
}
- Err(e) => print_error!("Can not open config file: {}.", e),
}
- None
}
/// This provides the path for a configuration file, inside the %APPDATA% directory.
/// return None if error like PermissionDenied
#[cfg(windows)]
pub fn config_file_path() -> Option<PathBuf> {
- if let Some(p) = dirs::config_dir() {
- return Some(p.join(CONF_DIR));
- }
- None
+ dirs::config_dir().map(|x| x.join(CONF_DIR))
}
/// This expand the `~` in path to HOME dir