🦀 Rust Nuggets

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.

Nugget 1

The Magic of parse()

How one method call does so much — FromStr, type inference, turbofish, and custom parseable types.

Nugget 2

Making Your Types Printable

Debug and Display — why println! won't work with your struct and how to fix it.

Nugget 3

Copying vs. Moving Values

Why values 'disappear' in Rust — the Copy and Clone traits and ownership basics.

Nugget 4

Comparing Things

Why == doesn't compile on your struct — PartialEq, Eq, and the NaN gotcha.

Nugget 5

Shared Behavior Across Types

Defining a trait, implementing it for Dog and Cat — Rust's version of an interface.

Nugget 6

One Function, Many Types

Trait bounds — fn greet<T: Speak>(a: &T) works with any type that implements Speak.

Nugget 7

Extension Traits

Adding methods to types you don't own — .is_email() on &str and the itertools crate.

Nugget 8

Trait Objects

Storing Dogs and Cats in the same VecBox<dyn Speak> and dynamic dispatch.


8 nuggets — a beginner-friendly tour through Rust's trait system