diff --git a/src/path.rs b/src/path.rs index 30a1c50da..ae2de3d8b 100644 --- a/src/path.rs +++ b/src/path.rs @@ -18,32 +18,16 @@ /// Returns the user configuration directory for fish. If the directory or one of its parents /// doesn't exist, they are first created. -/// -/// \param path The directory as an out param -/// Return whether the directory was returned successfully pub fn path_get_config() -> Option { - let dir = get_config_directory(); - if dir.success() { - Some(dir.path.clone()) - } else { - None - } + get_config_directory().path() } /// Returns the user data directory for fish. If the directory or one of its parents doesn't exist, /// they are first created. /// /// Volatile files presumed to be local to the machine, such as the fish_history will be stored in this directory. -/// -/// \param path The directory as an out param -/// Return whether the directory was returned successfully pub fn path_get_data() -> Option { - let dir = get_data_directory(); - if dir.success() { - Some(dir.path.clone()) - } else { - None - } + get_data_directory().path() } /// Returns the user cache directory for fish. If the directory or one of its parents doesn't exist, @@ -51,16 +35,8 @@ pub fn path_get_data() -> Option { /// /// Volatile files presumed to be local to the machine such as all the /// generated_completions, will be stored in this directory. -/// -/// \param path The directory as an out param -/// Return whether the directory was returned successfully pub fn path_get_cache() -> Option { - let dir = get_cache_directory(); - if dir.success() { - Some(dir.path.clone()) - } else { - None - } + get_cache_directory().path() } #[derive(Clone, Copy, Eq, PartialEq)] @@ -568,8 +544,8 @@ struct BaseDirectory { } impl BaseDirectory { - fn success(&self) -> bool { - self.err.is_none() + fn path(&self) -> Option { + self.err.is_none().then(|| self.path.clone()) } }