Rust ships with an excellent toolchain manager (rustup) and build tool (Cargo). This guide gets you running, debugging and building Rust in VS Code.

Install Rust

  • All platforms: run the installer from rustup.rs. On macOS/Linux it's a single curl command; on Windows download rustup-init.exe.

This installs rustc (compiler), cargo (build tool + package manager) and standard tooling. Verify: cargo --version

VS Code

Install the rust-analyzer extension — it provides IntelliSense, inline type hints and instant error checking. For debugging, also install CodeLLDB.

Create and run a project

cargo new hello
cd hello
cargo run

Cargo creates src/main.rs:

fn main() {
    let name = "Ada";
    println!("Hello, {name}!");
}

cargo run compiles and runs in one step.

Debug it

With CodeLLDB installed, set a breakpoint and press F5. VS Code builds a debug binary and stops at your breakpoint so you can inspect values and step through ownership-heavy code.

Build for release

cargo build            # debug build, fast to compile
cargo build --release  # optimised binary in target/release/

The release binary is self-contained — copy it and run it on any compatible machine. Use cargo check for a fast type/borrow check without producing a binary, and cargo clippy for extra lint suggestions.