Skip to lesson content
navan✳THE BUILD LABRUST
0/53 complete
BUILD LAB / RUST/ THE FIRST BUILD
BUILD NOTE 01 / 53

A compiler in your corner.

Build, run, and change your first Rust program.

BY NAVAN SAMI◷ 7 MIN READFOUNDATIONSRUST 2024

01 Understand the contract

Rust compiles source into a native executable. The compiler checks types and borrowing before your program runs; it cannot decide whether your product requirements are correct. rustc is the compiler. Cargo manages packages, builds, tests, and dependencies. Start with a small program you can explain, then use cargo check for fast feedback. A package created with cargo new has a Cargo.toml manifest and a src/main.rs binary entry point. In this course, each foundation example is complete and uses only the standard library; the cookbook introduces ecosystem crates in real projects.

02 Make it concrete

This is a complete standard-library example. Use Rust stable with the 2024 edition. Run it locally using the Rust workbench.

lessons/welcome/src/main.rs
fn main() {
    let project = "Build Lab";
    println!("Hello, {project}!");
    println!("Next: change one thing, then rebuild.");
}
↳ EXPECTED OUTPUT
Hello, Build Lab!
Next: change one thing, then rebuild.
  1. 1

    main is the entry point for this binary.

  2. 2

    println! is a macro; the exclamation mark is part of its name.

  3. 3

    Build the workbook crate with cargo run -p lesson_welcome, or compile this file with rustc --edition 2024 main.rs.

From the extracted rust-workbench folder
cargo run -p lesson_welcome

03 Mind the boundary

04 Your next build

A SMALL MISSION

Print your own project name and one small task you want to automate.

Reveal one possible solution +
solutions/welcome/src/main.rs
fn main() {
    let name = "File sorter";
    println!("Project: {name}");
    println!("First task: list a folder");
}

05 Check your reasoning

QUICK SIGNAL CHECK

Which tool manages packages and runs Rust tests?

ONE MORE CONTRACT YOU CAN EXPLAIN.

Understand it.
Then make it yours.

Run the example, try your own input, and explain the boundary. Log the lesson when the idea makes sense.

Built with curiosity. By Navan Sami. ↗Rust · Make the contract clear. Then build.