diff --git a/src/config.rs b/src/config.rs index 35fe0fb..819f96f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,13 +47,12 @@ impl Default for Config { /// Gets the configuration directory. Panics if unavailable. pub fn get_config_dir() -> PathBuf { std::env::var_os("XDG_CONFIG_HOME") - .map(PathBuf::try_from) - .expect("$XDG_CONFIG_HOME is unset.") - .unwrap_or_else(|_| { + .map(|p| PathBuf::try_from(p).expect("$XDG_CONFIG_HOME is not a valid path.")) + .unwrap_or_else(|| { std::env::var_os("HOME") .map(PathBuf::try_from) - .expect("User has no $HOME.") - .unwrap() + .expect("$HOME is not a valid path.") + .expect("User has no $HOME or $XDG_CONFIG_HOME.") .join(".config") }) .join("breed") @@ -61,13 +60,12 @@ pub fn get_config_dir() -> PathBuf { pub fn get_data_dir() -> PathBuf { std::env::var_os("XDG_DATA_HOME") - .map(PathBuf::try_from) - .expect("$XDG_DATA_HOME is unset.") - .unwrap_or_else(|_| { + .map(|p| PathBuf::try_from(p).expect("$XDG_DATA_HOME is not a valid path.")) + .unwrap_or_else(|| { std::env::var_os("HOME") .map(PathBuf::try_from) - .expect("User has no $HOME.") - .unwrap() + .expect("$HOME is not a valid path.") + .expect("User has no $HOME or $XDG_DATA_HOME.") .join(".local/share") }) .join("breed")