diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 21 | 
1 files changed, 11 insertions, 10 deletions
| diff --git a/src/main.rs b/src/main.rs index 2f608df..76967b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,8 +18,6 @@ use regex::Regex;  use structopt::StructOpt;  use walkdir::{DirEntry, WalkDir}; -use rayon::prelude::*; -  use evtclib::{AgentKind, AgentName, EventKind, Log};  mod errors; @@ -211,14 +209,17 @@ fn is_log_file(entry: &DirEntry) -> bool {  /// Run the grep search with the given options.  fn grep(opt: &Opt) -> Result<(), RuntimeError> { -    let walker = WalkDir::new(&opt.path); -    let entries = walker.into_iter().collect::<Vec<_>>(); -    entries.into_par_iter().try_for_each(|e| { -        let entry = e?; -        if is_log_file(&entry) { -            if let Some(result) = search_log(&entry, opt)? { -                output::colored(io::stdout(), &result)?; -            } +    rayon::scope(|s| { +        let walker = WalkDir::new(&opt.path); +        for entry in walker { +            let entry = entry?; +            s.spawn(move |_| { +                if is_log_file(&entry) { +                    if let Some(result) = search_log(&entry, opt).unwrap() { +                        output::colored(io::stdout(), &result).unwrap(); +                    } +                } +            });          }          Ok(())      }) | 
