Rust and Cargo 1 cheatsheet

Rust and Cargo 1: Build and run

8 common Rust and Cargo 1 tasks.

Type-check quickly

Check that the code compiles without producing a binary. Much faster than a build.

cargo check

Build in debug mode

Compile the project with debug info and no optimization.

cargo build

Build for release

Compile with optimizations into target/release.

cargo build --release

Run the project

Build and run the binary.

cargo run

Run with arguments

Pass arguments to your program after the double dash.

cargo run --release -- --port 8080

Show a backtrace on panic

Set RUST_BACKTRACE to see where a panic came from.

RUST_BACKTRACE=1 cargo run

Delete build output

Remove the target folder to free disk space or force a full rebuild.

cargo clean

Build and open documentation

Build the docs for your crate and its dependencies and open them in a browser.

cargo doc --open

Was this page helpful?