refactor(zplug): remove match expressions

This commit is contained in:
Eric Mark Martin
2019-02-26 03:14:40 -08:00
parent 6003ffc83c
commit 79cb5a5284

View File

@@ -8,20 +8,15 @@ use std::path::Path;
use std::process::Command; use std::process::Command;
fn zplug_exists(base_dirs: &BaseDirs) -> bool { fn zplug_exists(base_dirs: &BaseDirs) -> bool {
let home_exists = match env::var("ZPLUG_HOME") { env::var("ZPLUG_HOME")
Ok(ref zplug_home) => Path::new(zplug_home).exists(), .map(|ref zplug_home| Path::new(zplug_home).exists())
Err(_) => false, .map(|p| p || base_dirs.home_dir().join("zplug").exists())
}; .unwrap_or(false)
let dotdir_exists = base_dirs.home_dir().join(".zplug").exists();
home_exists || dotdir_exists
} }
fn get_zshrc(base_dirs: &BaseDirs) -> Result<String, ()> { fn get_zshrc(base_dirs: &BaseDirs) -> Result<String, ()> {
let zshrc = match env::var("ZDOTDIR") { env::var("ZDOTDIR")
Ok(ref zdotdir) => Ok(Path::new(zdotdir).join(".zshrc")), .map(|ref zdotdir| Path::new(zdotdir).join(".zshrc"))
Err(_) => Err(()),
};
zshrc
.unwrap_or_else(|_| base_dirs.home_dir().join(".zshrc")) .unwrap_or_else(|_| base_dirs.home_dir().join(".zshrc"))
.to_str() .to_str()
.map(|s| s.to_owned()) .map(|s| s.to_owned())