$ show mainmatter/100-exercises-to-learn-rust
This repository is a comprehensive, hands-on Rust course consisting of ~100 exercises that progressively teach Rust's core concepts, from basic syntax and ownership to concurrency and async programming. It is structured as a monorepo with a book (mdbook) and a set of exercise crates, each with its own tests. The code is well-crafted, demonstrating idiomatic Rust patterns such as newtypes with validation, error handling via thiserror, and safe concurrency with channels and locks. While not a production application, the exercises serve as a high-quality reference for Rust best practices and are actively maintained by Mainmatter.
The LLM identified 3 files worth highlighting for reuse:
Implements a `TicketTitle` newtype with fallible conversion from `String` and `&str`, enforcing non-empty and max-length constraints. Uses `thiserror` for error types and demonstrates a clean, reusable pattern for domain-driven validation that can be extracted to any Rust project.
Mirrors `TicketTitle` for `TicketDescription`, enforcing non-empty and max-length (500 bytes) constraints. Provides a reusable pattern for validated string types with clear error messages.
Implements a 'DropBomb' type that panics on drop unless defused. This is a reusable testing utility pattern for ensuring that certain cleanup or finalization operations are performed before a value is dropped, useful for testing resource management.