Defense Against The Wrong Logic: Proactive Rust Coding
summary
Shows concrete moves: use newtype wrappers with the Into trait to make a Celsius→Fahrenheit conversion that actually fails to compile if you mix units, build a GitHub client with the Builder pattern so invalid request states are unrepresentable, parse inputs early with serde_json (or nom / pest) into typed responses, prefer assertions and labeled expect messages over blind unwraps, and minimize and document unsafe blocks (one-line scopes, unsafe functions with invariants). These patterns aim to catch logic errors at compile or parse time and reduce 3am on‑call wakeups.
AI-written summary · about
chapters (9)
- 0:00Intro
- 1:16New types
- 1:54Type alias
- 6:43Builder Pattern
- 10:28Converting Input
- 16:49Unwrap Expect
- 21:13Unsafe
- 24:10Guidelines
- 29:58Outro
related talks
21m“Fearless Refactoring & the Art of Argument-Free Rust”
26mThe Freedom of Static Typing
25m"Compiler-Driven Development: Making Rust Work for You"
19mRust Without Tears: A Guide to Avoiding Common Traps
32mBuilding and Maintaining Rust at Scale
46mKeynote: Rust is not about memory safety
40mRust’s approach of getting things right
01h 22mRust for the C++ Programmer
