From 083c0515d2db0ab2a064de7018e2b1f6cad94691 Mon Sep 17 00:00:00 2001 From: hinto-janai Date: Wed, 21 Feb 2024 12:55:29 -0500 Subject: [PATCH] helper: `NON_ZERO_USIZE_1` -> `NonZeroUsize::MIN` (#70) thread: `NON_ZERO_USIZE_1` -> `NonZeroUsize::MIN` --- helper/src/thread.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/helper/src/thread.rs b/helper/src/thread.rs index 2567330..96958ff 100644 --- a/helper/src/thread.rs +++ b/helper/src/thread.rs @@ -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