cargo-kit 0.1.10

Cargo subcommand to apply performance, compile-time, or size-optimized profiles and configs to your Rust project for enhanced build efficiency.
Documentation
1
2
3
4
5
6
7
8
9
10
use std::num::NonZeroUsize;

/// Find the number of cores on the current device, or return a default of `8`.
pub fn get_core_count() -> i64 {
    std::thread::available_parallelism()
        .unwrap_or(NonZeroUsize::new(8).unwrap())
        .get()
        .try_into()
        .expect("Cannot convert number of CPUs")
}