Curriculum Production Rust Idioms and tooling
Idioms and tooling
This final theme is the code-review survival kit: rustfmt, Clippy, docs, Result in main, todo! vs unimplemented!, prelude habits, and avoiding needless clone, unwrap, and type annotations. Planned exercises: 1. choose cargo fmt. 2. recognise a Clippy suggestion. 3. choose expect over blind unwrap when panicking is intentional. 4. fill a main() -> Result. 5. fill a doc comment. 6. write a small polished CLI-style main. 7. remove needless clones. 8. translate a TS script into idiomatic Rust structure. 9. refactor a rough program into the idioms taught across the course.
Exercises
9 ready
01
pick one
Pick the Cargo command that auto-formats every .rs file in
02
pick one
Clippy suggests replacing **x > 0 inside a closure with
03
pick one
A parse MIGHT fail, and if it does you want a CLEAR panic
04
type one line
Fill the main signature that lets you use ? at the TOP
05
fill blanks
Fill the Rust DOC-COMMENT prefix — the one that generates
06
write a program
Write a polished CLI-style main that returns
07
write a program
This program has two NEEDLESS clones. Remove them both —
08
write a program
Translate the TS script to idiomatic Rust. Filter even numbers,
09
write a program
Refactor this rough program. Replace the verbose Vec::new +