What Rust checks.
See the compiler, Cargo, and the promises a successful build actually makes.
The idea behind the syntax.
Rust is a compiled language: source code becomes an executable after a compiler checks its syntax, types, and a set of ownership rules. Those checks happen before the program runs. They can reject a reference that might outlive its data, but they cannot know whether your invoice calculation is correct. The useful mental model is a partnership: the compiler enforces language contracts; you still define the product's meaning.
A Rust package is described by Cargo.toml and contains source under src. Cargo resolves dependencies and orchestrates checking, compiling, running, and testing. The compiler rustc performs the language checks. This division matters when you read an error: a manifest or dependency problem is different from a type or borrow error in the source. The 2024 edition selects a set of language rules and idioms; it is declared in the manifest rather than implied by the date on your machine.
What Rust is checking.
A binary crate has a main function as its entry point. A library crate exposes functions and types to callers. A macro call such as println! has an exclamation mark because it expands syntax before ordinary compilation continues; it is not a regular function call. In a simple program, statements inside main execute in order and values leave scope at the closing brace.
A clean build is evidence that the program obeys the compiler's rules. It is not proof of useful behavior, reliable input handling, or a stable public API. Read a code example by asking what each binding owns, what each function returns, and which assumptions the type system can check. That habit will make later concepts such as borrowing and concurrency feel like extensions of one model rather than separate tricks.
See the rule in context.
Each example isolates one part of the model. Follow the bindings, types, ownership transfers, and possible outcomes line by line.
Rust, rustc & Cargo
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.
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.
- main is the entry point for this binary.
- println! is a macro; the exclamation mark is part of its name.
- Build the workbook crate with cargo run -p lesson_welcome, or compile this file with rustc --edition 2024 main.rs.
The boundary: A successful compile is evidence of language-rule compliance, not a proof that the program meets its specification.
Cargo manifests & dependencies
Cargo.toml declares package metadata, an edition, and dependencies. Cargo.lock records resolved dependency versions for reproducibility and should be committed for these executable workbook projects. An edition selects language rules and migration boundaries; it is not the compiler version. cargo check type-checks without a final executable, cargo test runs tests, cargo fmt formats, and cargo clippy offers additional diagnostics. Features are additive configuration switches: inspect which optional capabilities a dependency enables instead of adding every feature by default.
fn main() {
let manifest = "[package]\nname = \"first-build\"\nversion = \"0.1.0\"\nedition = \"2024\"\n";
println!(
"{}",
manifest
.lines()
.find(|line| line.starts_with("edition"))
.unwrap()
);
}edition = "2024"
- A manifest is configuration rather than Rust source.
- The workbook generates a proper manifest per lesson.
- Run cargo check, cargo test, and cargo fmt --check from the workspace root as appropriate.
The boundary: A semver requirement such as 1 allows compatible updates. A committed lockfile pins the actual resolved graph until updated.
Keep this model.
Rust's checks are strongest when the program's contracts are expressed in its types and ownership relationships. Tests and review still establish whether the contract is the right one.