Description
Cargo is Rust’s build system and package manager.
Configuration
Commands
Create project
Build & run project
Backtrace
When you want to see an error backtrace set the RUST_BACKTRACE
environment variable:
Publish to Crates.io
Install package
Linting & testing
Check code
Testing
-
Backtrace
To backtrace set the
RUST_BACKTRACE
environment variable: -
Threads
By default cargo runs test in parallel. For more control over this you can pass the number of threads you want to use. For example to only use 1 thread:
-
Show output for passing tests as well as failed tests
-
Pass test name to cargo (this equals test function name)
-
Run ignored tests
Fix
The rustfix tool is included with Rust installations and can automatically fix some compiler warnings.
Builds
Profiles
In Rust, release profiles are predefined and customizable profiles with different configurations that allow a programmer to have more control over various options for compiling code. Each profile is configured independently of the others.
Cargo has two main profiles: the dev
profile Cargo uses when you run
cargo build and the release profile Cargo uses when you run
cargo build --release
. The dev
profile is defined with good defaults
for development, and the release
profile has good defaults for release
builds.
-
dev
-
build
Documentation
See Rust Comments for documentation syntax.