-4

I was wondering how are Rust crates are implemented.

For example, there is a crate named num_cpus. This crate has this basic method num_cpus::get() which tells number of CPUs in your computer.

My questions:

  • How is the method num_cpus::get() implemented (is it done using another language?)
  • Can the same result be achieved with plain Rust code without using any crates?
Lukas Kalbertodt
  • 79,749
  • 26
  • 255
  • 305

1 Answers1

3

... in Rust. There's no reason to believe it'd be anything else.

You can also check this by just looking at the source code, easily done by:

  1. Search crates.io for "num_cpus"..
  2. Select the num_cpus crate.
  3. Select "Repository" for the source code.
  4. Open the only .rs source file in the repository, src/lib.rs.
DK.
  • 55,277
  • 5
  • 189
  • 162