diff --git a/src/reader.rs b/src/reader.rs index 7c1251b..fc2bc17 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -3,12 +3,11 @@ use std::{env, fs, path::PathBuf}; /// Read seeds from specified file pub fn read_file(filename: &str, base_dir: &str) -> Result { - let mut path = PathBuf::new(); - if let Ok(current_base) = env::var("CARGO_MANIFEST_DIR") { - path.push(current_base) - } - path.push(base_dir); - path.push(filename); + let path = env::var("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .unwrap_or_default() + .join(base_dir) + .join(filename); fs::read_to_string(&path) .map_err(|err| anyhow::anyhow!("Can't open the file: {:?}\n err: {}", path, err))