helper: NON_ZERO_USIZE_1 -> NonZeroUsize::MIN (#70)

thread: `NON_ZERO_USIZE_1` -> `NonZeroUsize::MIN`
This commit is contained in:
hinto-janai 2024-02-21 12:55:29 -05:00 committed by GitHub
parent e287ea1d84
commit 083c0515d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,13 +5,6 @@
//---------------------------------------------------------------------------------------------------- Use
use std::{cmp::max, num::NonZeroUsize};
//---------------------------------------------------------------------------------------------------- Constants
// FIXME: switch to `.unwrap()` when const stablized
const NON_ZERO_USIZE_1: NonZeroUsize = match NonZeroUsize::new(1) {
Some(t) => t,
_ => panic!(),
};
//---------------------------------------------------------------------------------------------------- Thread Count & Percent
#[allow(non_snake_case)]
/// Get the total amount of system threads.
@ -21,7 +14,7 @@ const NON_ZERO_USIZE_1: NonZeroUsize = match NonZeroUsize::new(1) {
/// assert!(threads().get() >= 1);
/// ```
pub fn threads() -> NonZeroUsize {
std::thread::available_parallelism().unwrap_or(NON_ZERO_USIZE_1)
std::thread::available_parallelism().unwrap_or(NonZeroUsize::MIN)
}
// Implement a function for the various