Make the build repeatable.
Understand packages, editions, lockfiles, features, and common commands.
01 Understand the contract
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.
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 manifest = "[package]\nname = \"first-build\"\nversion = \"0.1.0\"\nedition = \"2024\"\n";
println!(
"{}",
manifest
.lines()
.find(|line| line.starts_with("edition"))
.unwrap()
);
}edition = "2024"
- 1
A manifest is configuration rather than Rust source.
- 2
The workbook generates a proper manifest per lesson.
- 3
Run cargo check, cargo test, and cargo fmt --check from the workspace root as appropriate.
cargo run -p lesson_cargo_workflow03 Mind the boundary
04 Your next build
Write a function accepting a small list of enabled feature names and checking for one required feature.
Reveal one possible solution +
fn enabled(features: &[&str], name: &str) -> bool {
features.contains(&name)
}
fn main() {
assert!(enabled(&["json", "tls"], "tls"));
assert!(!enabled(&[], "tls"));
}05 Check your reasoning
Does edition = "2024" select a precise compiler version?
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.