From 806d7a6a353181ba43d034426c1583117c6bca8b Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 13 Feb 2019 14:01:28 +0100 Subject: [PATCH] tools/fs: change scan_subdir to use filter_file_name_regex Signed-off-by: Wolfgang Bumiller --- src/tools/fs.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/tools/fs.rs b/src/tools/fs.rs index 9f24acf2..25e04b33 100644 --- a/src/tools/fs.rs +++ b/src/tools/fs.rs @@ -107,24 +107,8 @@ pub fn scan_subdir<'a, P: ?Sized + nix::NixPath>( dirfd: RawFd, path: &P, regex: &'a regex::Regex, -) -> Result> + 'a, Error> { - Ok(read_subdir(dirfd, path)?.filter_map(move |entry| { - match entry { - Ok(entry) => match entry.file_name().to_str() { - Ok(name) => { - if regex.is_match(name) { - Some(Ok(entry)) - } else { - None // Skip values not matching the regex - } - } - // Skip values which aren't valid utf-8 - Err(_) => None, - }, - // Propagate errors through - Err(e) => Some(Err(Error::from(e))), - } - })) +) -> Result> + 'a, Error> { + Ok(read_subdir(dirfd, path)?.filter_file_name_regex(regex)) } /// Helper trait to provide a combinators for directory entry iterators.