Coverage Report

Created: 2025-07-11 06:39

/rust/registry/src/index.crates.io-6f17d22bba15001f/num_threads-0.1.7/src/lib.rs
Line
Count
Source (jump to first uncovered line)
1
//! Minimum supported Rust version: 1.28
2
3
use std::num::NonZeroUsize;
4
5
#[cfg_attr(any(target_os = "linux", target_os = "android"), path = "linux.rs")]
6
#[cfg_attr(target_os = "freebsd", path = "freebsd.rs")]
7
#[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "apple.rs")]
8
#[cfg_attr(target_os = "aix", path = "aix.rs")]
9
mod imp;
10
11
/// Obtain the number of threads currently part of the active process. Returns `None` if the number
12
/// of threads cannot be determined.
13
0
pub fn num_threads() -> Option<NonZeroUsize> {
14
0
    imp::num_threads()
15
0
}
16
17
/// Determine if the current process is single-threaded. Returns `None` if the number of threads
18
/// cannot be determined.
19
0
pub fn is_single_threaded() -> Option<bool> {
20
0
    num_threads().map(|n| n.get() == 1)
21
0
}