diff --git a/src/files.rs b/src/files.rs index 569e049..a47f8a7 100644 --- a/src/files.rs +++ b/src/files.rs @@ -151,17 +151,15 @@ pub fn scan_from_walkdir( // split the entries into chunks of 32, and iterate over each chunk of entries in a separate thread return entries .par_chunks(CHUNKS) - .map(|chunk| { + .flat_map_iter(|chunk| { chunk .iter() // iter over the chunk, which is a slice of DirEntry structs - .partition_map::, Vec<_>, _, _, _>(|entry| match scan_file(entry, canonical_paths) { - Ok(f) => Either::Left(f), - Err(e) => Either::Right(e) - } - ) - }) - .flatten() - .collect() + .map(|entry| scan_file(entry, canonical_paths)) + .collect::>() // TODO: is there a way to avoid having to collect here? + }).partition_map(|result| match result { + Ok(f) => Either::Left(f), + Err(e) => Either::Right(e), + }); } } else { // should always be false when multi-threading is disabled at compile time