A compiler in your corner.
Build, run, and change your first Rust program.
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.
fn main() {
let project = "Build Lab";
println!("Hello, {project}!");
println!("Next: change one thing, then rebuild.");
}Hello, Build Lab! Next: change one thing, then rebuild.
- 1
main is the entry point for this binary.
- 2
println! is a macro; the exclamation mark is part of its name.
- 3
Build the workbook crate with cargo run -p lesson_welcome, or compile this file with rustc --edition 2024 main.rs.
cargo run -p lesson_welcome03 Mind the boundary
04 Your next build
Print your own project name and one small task you want to automate.
Reveal one possible solution +
fn main() {
let name = "File sorter";
println!("Project: {name}");
println!("First task: list a folder");
}05 Check your reasoning
Which tool manages packages and runs Rust tests?
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.