From 04e7ae9ee6b15e1616c67b3f5055cc814a035886 Mon Sep 17 00:00:00 2001 From: Pablo Sichert Date: Sun, 10 Jan 2021 08:00:30 +0100 Subject: [PATCH] Simplify expression by unwrapping first --- lib/file-source/src/paths_provider/glob.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/file-source/src/paths_provider/glob.rs b/lib/file-source/src/paths_provider/glob.rs index fa51a703fed91b..f02cb178eadbeb 100644 --- a/lib/file-source/src/paths_provider/glob.rs +++ b/lib/file-source/src/paths_provider/glob.rs @@ -113,17 +113,16 @@ impl PathsProvider for Glob { })? .into_path(); - let is_excluded = self.exclude_patterns.iter().any(|exclude_pattern| { - path.to_str() - .map_or(false, |path| exclude_pattern.matches(path)) + let is_excluded = path.to_str().map_or(false, |path| { + self.exclude_patterns + .iter() + .any(|exclude_pattern| exclude_pattern.matches(path)) }); - // Exclude all paths that match the list of our exclude patterns. - if is_excluded { - continue; + // Only include paths that does not match the list of our exclude patterns. + if !is_excluded { + paths.push(path); } - - paths.push(path); } }