Core commands
| Command | Use it when… |
|---|---|
cargo new app-name --bin | Create a runnable binary project. |
cargo run | Compile and run the current package. |
cargo check | Ask the compiler for type/borrow errors without producing the final binary. Fast feedback. |
cargo fmt | Format code using the standard Rust style. |
cargo test | Run unit/integration tests. |
cargo build --release | Make an optimized binary for distribution or benchmarking. |
Files you will see
Cargo.toml
Manifest: package metadata, edition, dependencies, features.
src/main.rs
Entry point for a binary crate.
src/lib.rs
Entry point for reusable library code.
Cargo.lock
Exact dependency versions. Commit it for application projects.
Mutability rule
Rust bindings are immutable by default. If you plan to assign a new value to a binding, write let mut name = value;. This is not a performance trick; it is an explicitness and safety habit.
let count = 1;
count = count + 1; // compiler error
let mut count = 1;
count = count + 1; // ok