Skip to content

Commit

Permalink
tidy if into match
Browse files Browse the repository at this point in the history
  • Loading branch information
0jdxt committed Oct 28, 2020
1 parent f8ca998 commit 3430c54
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/meta/symlink.rs
Expand Up @@ -11,16 +11,12 @@ pub struct SymLink {
impl From<&Path> for SymLink {
fn from(path: &Path) -> Self {
path.read_link()
.map(|target| {
let parent = path.parent();
Self {
target: Some(target.to_string_lossy().into()),
valid: if target.is_absolute() || parent.is_none() {
target.exists()
} else {
parent.unwrap().join(target).exists()
},
}
.map(|target| Self {
target: Some(target.to_string_lossy().into()),
valid: match (path.parent(), target.is_absolute()) {
(Some(p), false) => p.join(target).exists(),
_ => target.exists(),
},
})
.unwrap_or_default()
}
Expand Down

0 comments on commit 3430c54

Please sign in to comment.