Coverage Report

Created: 2024-05-20 06:38

/rust/registry/src/index.crates.io-6f17d22bba15001f/num_threads-0.1.6/src/linux.rs
Line
Count
Source (jump to first uncovered line)
1
use std::fs;
2
use std::num::NonZeroUsize;
3
4
0
pub(crate) fn num_threads() -> Option<NonZeroUsize> {
5
0
    fs::read_to_string("/proc/self/stat")
6
0
        .ok()
7
0
        .as_ref()
8
0
        // Skip past the pid and (process name) fields
9
0
        .and_then(|stat| stat.rsplit(')').next())
10
0
        // 20th field, less the two we skipped
11
0
        .and_then(|rstat| rstat.split_whitespace().nth(17))
12
0
        .and_then(|num_threads| num_threads.parse::<usize>().ok())
13
0
        .and_then(NonZeroUsize::new)
14
0
}