Surprising, delightful, and deep aspects of Rust — one digestible nugget at a time
Every nugget reveals something about Rust's type system, trait system, or ownership model that you might not have noticed at first glance.
Rust code throughout. No other languages.
parse()How one method call does so much — FromStr, type inference, turbofish, and custom parseable types.
Debug and Display — why println! won't work with your struct and how to fix it.
Why values 'disappear' in Rust — the Copy and Clone traits and ownership basics.
Why == doesn't compile on your struct — PartialEq, Eq, and the NaN gotcha.
Defining a trait, implementing it for Dog and Cat — Rust's version of an interface.
Trait bounds — fn greet<T: Speak>(a: &T) works with any type that implements Speak.
Adding methods to types you don't own — .is_email() on &str and the itertools crate.
Storing Dogs and Cats in the same Vec — Box<dyn Speak> and dynamic dispatch.
The Iterator trait, next(), how for loops work, and iter vs into_iter vs iter_mut.
Why map / filter don't do anything until collect() — lazy evaluation vs JavaScript's eager arrays.
sum, count, fold, any, find — the many ways to finish an iteration.
take, skip, enumerate, zip, chain, step_by — composing with precision.
When map gives you nested iterators — flat_map and flatten to the rescue.
IntoIteratorThe trait behind every for loop — and making your own types iterable.
map / and_then on Option and Result, and collecting Results in one shot.
vec! MacroWhy vec! is a macro, not a function — and the three things it can do that Vec::new() can't.
Vec CapacityWhen Vec::new() causes 20 reallocations and with_capacity() causes one — Vec's growth strategy.
Why filter(|&x|) needs an extra & but map(|x|) doesn't — tracing reference layers.
When to call .iter(), .iter_mut(), or .into_iter() — the three ownership stories.
19 nuggets — from traits to iterators, a beginner-friendly tour through Rust's core abstractions