1 //! Helper module which helps to determine amount of threads to be used
2 //! during tests execution.
7 pub fn get_concurrency() -> usize {
8 match env::var("RUST_TEST_THREADS") {
10 let opt_n: Option<usize> = s.parse().ok();
12 Some(n) if n > 0 => n,
13 _ => panic!("RUST_TEST_THREADS is `{}`, should be a positive integer.", s),
16 Err(..) => thread::available_concurrency().map(|n| n.get()).unwrap_or(1),