From ce92ec5e8770ba9eadf21b26c23b874f57346b8b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 27 Jul 2019 11:06:04 +0300 Subject: [PATCH] process_files on a slice --- src/main.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 57f19db..f754e59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,7 +219,7 @@ fn split_vec<'a, T>(src: &'a [T], num: usize) -> Vec<&'a [T]> { result } -fn process_files(files: Vec) { +fn process_files(files: &&[PathBuf]) { let zip_file = fs::File::open(BASE_FILENAME).unwrap(); let zip_reader = io::BufReader::new(zip_file); let mut archive = zip::ZipArchive::new(zip_reader).unwrap(); @@ -264,13 +264,9 @@ fn main() -> Result<(), Box> { .collect(); drop(archive); - //split vector and iterate on it parts in parallel + // split vector and process its parts in parallel split_vec(&source_files, rayon::current_num_threads()) .par_iter() - .for_each(|slice| { - let source_files_part = slice.to_vec(); - process_files(source_files_part); - }); - + .for_each(process_files); Ok(()) }