mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 11:39:26 +00:00
helper: NON_ZERO_USIZE_1
-> NonZeroUsize::MIN
(#70)
thread: `NON_ZERO_USIZE_1` -> `NonZeroUsize::MIN`
This commit is contained in:
parent
e287ea1d84
commit
083c0515d2
1 changed files with 1 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue