From 972a764a7468285bcd9270328f80352e1e24990e Mon Sep 17 00:00:00 2001 From: sharkdp Date: Thu, 7 Feb 2019 21:20:35 +0100 Subject: [PATCH] Simplify Optional handling --- src/dirs.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/dirs.rs b/src/dirs.rs index 29e79b2e..edd55f39 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -25,10 +25,7 @@ impl BatProjectDirs { #[cfg(not(target_os = "macos"))] let cache_dir_op = dirs_rs::cache_dir(); - let cache_dir = match cache_dir_op { - Some(d) => d.join("bat"), - None => return None, - }; + let cache_dir = cache_dir_op.map(|d| d.join("bat"))?; #[cfg(target_os = "macos")] let config_dir_op = env::var_os("XDG_CONFIG_HOME") @@ -39,10 +36,7 @@ impl BatProjectDirs { #[cfg(not(target_os = "macos"))] let config_dir_op = dirs_rs::config_dir(); - let config_dir = match config_dir_op { - Some(d) => d.join("bat"), - None => return None, - }; + let config_dir = config_dir_op.map(|d| d.join("bat"))?; Some(BatProjectDirs { cache_dir,