rewrite: Reduce indentation with guard clause

This commit is contained in:
Teemu Pätsi
2025-03-10 18:36:38 +02:00
committed by andy.boot
parent c31468b199
commit b219981c52
+3 -4
View File
@@ -69,14 +69,13 @@ pub fn normalize_path<P: AsRef<Path>>(path: P) -> PathBuf {
// Canonicalize the path only if it is an absolute path // Canonicalize the path only if it is an absolute path
pub fn canonicalize_absolute_path(path: PathBuf) -> PathBuf { pub fn canonicalize_absolute_path(path: PathBuf) -> PathBuf {
if path.is_absolute() { if !path.is_absolute() {
return path;
}
match std::fs::canonicalize(&path) { match std::fs::canonicalize(&path) {
Ok(canonicalized_path) => canonicalized_path, Ok(canonicalized_path) => canonicalized_path,
Err(_) => path, Err(_) => path,
} }
} else {
path
}
} }
pub fn is_filtered_out_due_to_regex(filter_regex: &[Regex], dir: &Path) -> bool { pub fn is_filtered_out_due_to_regex(filter_regex: &[Regex], dir: &Path) -> bool {