🦀 Rust Beginner

What is Cargo and what are its main commands?

Answer

Cargo is Rust's official build system and package manager, included with every Rust installation. Key commands: cargo new my-project creates a new project with a Cargo.toml manifest and a src/main.rs entry point. cargo build compiles the project in debug mode (fast compilation, no optimizations). cargo build --release compiles with full optimizations for production. cargo run compiles and executes the project. cargo test runs all unit and integration tests. cargo add serde adds a dependency. cargo check type-checks code without producing a binary (much faster than a full build — ideal during development). cargo doc --open generates and opens HTML documentation.