From 82e6562cfc5f964668cbce764db20518d3a6131f Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 28 Feb 2020 13:10:52 +0100 Subject: [PATCH] Further simplify the code --- src/walk.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index a4da080..594c87c 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -61,12 +61,11 @@ impl TryFrom for PathBuf { WorkerResult::Error(ignore_error) => { if let ignore::Error::WithPath { path, err } = &ignore_error { if let ignore::Error::Io(ref io_err) = **err { - if io_err.kind() == io::ErrorKind::NotFound { - if let Ok(metadata) = fs::symlink_metadata(&path) { - if metadata.file_type().is_symlink() { - return Ok(path.to_path_buf()); - } - } + if io_err.kind() == io::ErrorKind::NotFound + && fs::symlink_metadata(&path) + .map_or(false, |m| m.file_type().is_symlink()) + { + return Ok(path.to_path_buf()); } } }