mirror of
https://github.com/bootandy/dust.git
synced 2025-12-12 07:40:40 -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
|
||||
pub fn canonicalize_absolute_path(path: PathBuf) -> PathBuf {
|
||||
if path.is_absolute() {
|
||||
match std::fs::canonicalize(&path) {
|
||||
Ok(canonicalized_path) => canonicalized_path,
|
||||
Err(_) => path,
|
||||
}
|
||||
} else {
|
||||
path
|
||||
if !path.is_absolute() {
|
||||
return path;
|
||||
}
|
||||
match std::fs::canonicalize(&path) {
|
||||
Ok(canonicalized_path) => canonicalized_path,
|
||||
Err(_) => path,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user