Make illegal states unrepresentable
Rust's type system is not a formality you satisfy on the way to a running program: it is the cheapest place to encode the rules of your domain. This workshop is about using it that way.
You will work through a series of test-driven exercises, building minidb, a small embedded key-value
store, one API design decision at a time. By the end you will have a library whose misuse is a
compile-time error rather than a production incident.
This workshop is designed for people who are comfortable writing Rust and want to get better at designing Rust APIs that other people have to live with.
Note
This workshop has been written by Mainmatter.
It's one of the trainings in our portfolio of Rust workshops.
Check out our landing page if you're looking for Rust consulting or training!
Open the companion book for this course in your browser. Follow the instructions there to get started.
- Rust (follow instructions here).
If Rust is already installed on your system, make sure you are running on the latest compiler version (cargo --version).
If not, update usingrustup update(or another appropriate command depending on how you installed Rust on your system). - (Optional) An IDE with Rust autocompletion support.
We recommend one of the following:
- RustRover;
- Visual Studio Code with the
rust-analyzerextension.
You can find the solutions to the exercises in the solutions branch of this repository.
Throughout the workshop, the following resources might turn out to be useful:
- Rust Book
- Rust documentation (you can also open the documentation offline with
rustup doc!) - Rust API Guidelines
- The
std::markermodule
Copyright © 2026- Mainmatter GmbH (https://mainmatter.com), released under the Creative Commons Attribution-NonCommercial 4.0 International license.