diff --git a/src/args.rs b/src/args.rs index c8d859b..8660ef2 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,5 +1,6 @@ use clap::{Parser, ArgAction}; use glob::Pattern; +use rayon::ThreadPoolBuilder; use crate::unit::Unit; @@ -150,6 +151,11 @@ impl Args { self.path = vec![ ".".to_owned() ]; } + ThreadPoolBuilder::new() + .num_threads(self.threads) + .build_global() + .expect("Failed to initialise threadpool"); + self } @@ -195,10 +201,6 @@ impl Args { pub const fn quiet(&self) -> bool { self.quiet } - - pub const fn threads(&self) -> usize { - self.threads - } pub fn paths(&self) -> Iter<'_, String> { self.path.iter() diff --git a/src/main.rs b/src/main.rs index bfe89fd..fa838ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,23 +8,12 @@ use clap::Parser; use args::Args; use directory::Directory; -use rayon::ThreadPoolBuilder; use std::process::ExitCode; fn main() -> ExitCode { let args = Args::parse().post_process(); - match ThreadPoolBuilder::new().num_threads(args.threads()).build_global() { - Ok(()) => (), - Err(e) => { - if !args.minimal() && !args.quiet() { - eprintln!("hb: {e}"); - } - return ExitCode::FAILURE; - } - }; - let mut total = 0; for path in args.paths() { let dir_structure = match Directory::new(path, &args) {