Rust: Types & Traits
Make the wrong program unwriteable
Most Rust is not about the borrow checker. It is about choosing the enum that cannot hold the bad value, carrying a failure as a value instead of throwing it, and naming the one ability a function actually needs — then reading code somebody else wrote and knowing what it does.
- Modules
- 6
- Drills
- 10
- Build steps
- 5
- Time
- ~4h
Walk out able to
Read unfamiliar Rust and say what it produces — and choose between a generic parameter and a `dyn` without guessing which one the design needs.
What you work on
Enums that refuse bad states
Variants that differ, and a match that has to be total.
Option, Result and ?
Absence and failure carried as values, never thrown.
Generics and traits
One bound per ability — then generic or dyn, on purpose.
Pipelines, then the build
Adapters instead of loops, and a Rust program that runs.
What you get
Skills that stick
Every project mixes short lessons, focused drills and real build steps, so you finish with working code and the judgement behind it.
You will practise
- Enum shape, match arms, exhaustiveness
- Option, Result, combinators and ?
- Trait bounds, dyn, object safety
- Iterator chains and the three iters
Afterwards you can
- Pick the enum that refuses the bad value
- Carry a failure out with ? and no panic
- Name the bound a rejected line asked for
- Choose a generic or a dyn, and say why
Modules
Step by step
Each module builds on the last. Read a short lesson, drill it until it's second nature, then put it to work.
- 1
Make the states explicit
~40 minChoose the type that refuses the bad value, then read any match over it.
- LessonGive the states one type17 min
- DrillChoose the definition that refuses it12 min
- DrillSay which arm runs11 min
- 2
Absence and failure are values
~39 minCarry a missing or failed result through a program without unwrapping it.
- LessonCarry the failure instead of throwing it16 min
- DrillSay what the chain evaluates to12 min
- DrillFollow a failure out of a function11 min
- 3
One function, many types
~25 minWrite a generic function, bound it, and read the error when the bound is missing.
- LessonWrite it once, for every type13 min
- DrillName the bound the body needs12 min
- 4
Behaviour as a contract
~40 minName a behaviour, require it, and choose how the caller carries it.
- LessonName the behaviour, then require it16 min
- DrillPick the one the design needs13 min
- DrillSay whether it can be a trait object11 min
- 5
Pipelines instead of loops
~36 minPredict what an adapter chain produces, and start it with the right one of three.
- LessonSay what you want, not how to loop14 min
- DrillSay what the pipeline produces13 min
- DrillStart the loop with the right one9 min
- 6
Build the reader
~50 minGet the spellings under your fingers, then ship a Rust program that uses all five.
- DrillWrite the syntax from memory9 min
- Build stepModel the log as one enum5 min
- Build stepFill the type from the text7 min
- Build stepBreak it with one bad number4 min
- Build stepPut the checks behind one trait13 min
- Build stepFinish it with one pipeline12 min
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
Ready when you are.
Work through it at your own pace and pick up right where you left off.