We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dfeb3ec commit 91850d3Copy full SHA for 91850d3
std/src/sys/pal/wasi/thread.rs
@@ -192,8 +192,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
192
if #[cfg(target_feature = "atomics")] {
193
match unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) } {
194
-1 => Err(io::Error::last_os_error()),
195
- 0 => Err(io::Error::UNKNOWN_THREAD_COUNT),
196
- cpus => Ok(unsafe { NonZero::new_unchecked(cpus as usize) }),
+ cpus => NonZero::new(cpus as usize).ok_or(io::Error::UNKNOWN_THREAD_COUNT),
197
}
198
} else {
199
crate::sys::unsupported()
0 commit comments