From 7d17e904fc9e1737b440879b9bac1a6ee80da8db Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 25 Aug 2022 15:50:37 +0300 Subject: [PATCH] fmt --- src/main.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2987064..fd6a404 100644 --- a/src/main.rs +++ b/src/main.rs @@ -244,22 +244,21 @@ impl SplitTo for Vec { } } - fn process_files(files: &&[PathBuf]) { if files.is_empty() { return; } - + let start_file = files[0].to_str().unwrap(); println!("-> start from \"{}\" ({} files)", start_file, files.len()); - + 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(); files.iter().for_each(|name| { let name_str = name.to_str().unwrap(); - + // parse txt file let file = archive.by_name(name_str).unwrap(); let data = parse_file(file).unwrap(); @@ -273,7 +272,7 @@ fn process_files(files: &&[PathBuf]) { let mut outfile = fs::File::create(outfilename).unwrap(); data.write_pretty(&mut outfile, 1).unwrap(); }); - + println!("<- done {} files (from \"{}\")", files.len(), start_file); } @@ -297,23 +296,27 @@ fn main() -> Result<(), Box> { }) .collect(); drop(archive); - + // check output directory let out_dir: PathBuf = OUTPUT_PATH.into(); if out_dir.is_file() { - return Err("output directory is file!".into()); - } - else if !out_dir.exists() { + return Err("output directory is file!".into()); + } else if !out_dir.exists() { fs::create_dir_all(out_dir)?; }; - - println!("processing {} files with {} threads...", source_files.len(), rayon::current_num_threads()); - + + println!( + "processing {} files with {} threads...", + source_files.len(), + rayon::current_num_threads() + ); + // split vector and process its parts in parallel - source_files.split_to(rayon::current_num_threads()) + source_files + .split_to(rayon::current_num_threads()) .par_iter() .for_each(process_files); - + println!("done"); Ok(()) }