RustCargo

Download Rust for free

Introduction

Cargo is Rust's package manager, used to manage crates (Rust's term for libraries/packages). Cargo predominantly fetches packages from crates.io and can manage complex dependency trees with specific version requirements (using semantic versioning). Cargo can also help build, run and manage Rust projects with cargo build, cargo run and cargo test (among other useful commands).

Syntax

  • cargo new crate_name [--bin]
  • cargo init [--bin]
  • cargo build [--release]
  • cargo run [--release]
  • cargo check
  • cargo test
  • cargo bench
  • cargo update
  • cargo package
  • cargo publish
  • cargo [un]install binary_crate_name
  • cargo search crate_name
  • cargo version
  • cargo login api_key

Remarks

  • At the moment, the cargo bench subcommand requires the nightly version of the compiler to operate effectively.

Related Examples

Build project