O'Reilly logo

Rust Essentials by Ivo Balbaert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with Cargo

Cargo is Rust's package and dependency manager, and it is similar to Bundler, npm, pub, or pip for other languages. Although you can write Rust programs without it, Cargo is nearly indispensable for any large project; it works the same whether you work on a Windows, Linux, or a Mac OS X system. The installation procedure from the previous section includes the Cargo tool, so Rust is shipped with tooling included.

Cargo does the following things for you:

  • It makes a tidy folder structure and some templates for your project with the cargo new command
  • It compiles (builds) your code by using the cargo build command
  • It runs your project by using cargo run
  • If your project contains unit tests, it can execute them for you by using cargo test ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required