mirror of
https://github.com/bootandy/dust.git
synced 2025-12-12 15:49:58 -08:00
rewrite: Reduce indentation with guard clause
This commit is contained in:
13
src/utils.rs
13
src/utils.rs
@@ -69,13 +69,12 @@ 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() {
|
||||||
match std::fs::canonicalize(&path) {
|
return path;
|
||||||
Ok(canonicalized_path) => canonicalized_path,
|
}
|
||||||
Err(_) => path,
|
match std::fs::canonicalize(&path) {
|
||||||
}
|
Ok(canonicalized_path) => canonicalized_path,
|
||||||
} else {
|
Err(_) => path,
|
||||||
path
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user