From 1d61c2b439ca57258ad414e5ec58771fd96e3f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 8 Jul 2022 13:47:08 +0200 Subject: [PATCH] Better error handling. --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c64559..e70dfca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,11 +74,10 @@ fn main() let opts = Opts::from_args(); let mut hmgr = HabitMgr::new(); - let mut data_dir = PathBuf::from( - env::var("XDG_DATA_HOME") - .unwrap_or("./".to_string())); - // TODO: don't add this if we use ./ - data_dir.push("htracker"); + let data_dir:PathBuf = match env::var("XDG_DATA_HOME") { + Ok(s) => [ s, "htracker".to_string() ].iter().collect(), + Err(_e) => PathBuf::from("./"), + }; if !data_dir.exists() {