| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#; |
| 3 | |
| 4 | pub(craterust-analyzer cargo num_threads 0.1.7 crate/) fn num_threadsrust-analyzer cargo num_threads 0.1.7 imp/num_threads().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#> { |
| 5 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().("/proc/self/stat") |
| 6 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 7 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 8 | // Skip past the pid and (process name) fields |
| 9 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|stat| stat.rsplitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rsplit().(')').nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`RSplit<'a, P>`][Iterator]next().()) |
| 10 | // 20th field, less the two we skipped |
| 11 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|rstat| rstat.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(17)) |
| 12 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|num_threads| num_threads.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<usize>().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 13 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().) |
| 14 | } |