inflearn logo

Clean Rust Code: Idioms and Design Patterns

40 lessons on patterns and anti-patterns for writing idiomatic Rust code. Following the book’s table of contents, it explains everything from generics, traits, and iterators to builders, observers, state machines, and the overuse of unsafe and clone.

2 learners are taking this course

Level Intermediate

Course period Unlimited

Rust
Rust
Design Pattern
Design Pattern
rust-traits
rust-traits
generic
generic
macro
macro
Rust
Rust
Design Pattern
Design Pattern
rust-traits
rust-traits
generic
generic
macro
macro

What you will gain after the course

  • Choose generics, `Option`, trait bounds, and trait objects according to the purpose.

  • Write flow concisely and safely using pattern matching, the ? operator, closures, and iterators.

  • Learn the idioms of RAII, passing by value/reference, constructors, error handling, and managing global state.

  • Implements declarative and procedural macros, builders, fluent interfaces, observers, commands, and the newtype pattern.

  • Design the library API and refine it with rustdoc and tests

  • Avoid anti-patterns such as `unsafe`, `unwrap`, excessive cloning, and `Deref` polymorphism.

[必讀] You must have the book 《Rust Clean Code》 to take this course.
- The slides and videos do not include source code. Instead, you will follow along by opening the corresponding code listings in the book.
- If you do not purchase the book, you will not be able to view the code listings and follow the course. Please purchase the book before taking the course.
- The book is not included with this course and must be purchased separately.

📕 Required Textbook Information
- Book title: 《Clean Code in Rust》 (original title: Idiomatic Rust, Manning Publications, 2024)
- Author: Brenden Matthews
- Translator: Indo Yoon (personally translated by the knowledge provider of this course)
- Publisher: J-Pub Co., Ltd. (www.jpub.kr)
- Publication date: September 4, 2025 (1st edition, 1st printing)
- ISBN: 979-11-94587-32-3 (93000)
- Length: Approximately 300 pages
- The book’s price is listed on the back cover, and the book is not included in the price of this course.
- This course follows the book’s chapters, sections, and code listing numbers (e.g., Listing 2.1), so you cannot view the code without the book.
- Where to buy: Please search for the title above or the ISBN at a bookstore (online or offline) and purchase it.

This course organizes patterns and antipatterns into 40 lessons to help you move from being able to “write” code in Rust to “writing it the Rust way.”

Structure
- Part 1 (Lessons 1–12): Generics and Option, marker and phantom types, traits and trait objects, pattern matching, the ? operator, closures, and iterators
- Part 2 (Lessons 13–28): RAII, passing values and references, constructors, error handling, global state, macros, the Builder, Fluent, Observer, Command, and Newtype patterns, library design, rustdoc, testing, and debugging
- Part 3 (Lessons 29–35): Const generics, Extension, Blanket, and Marker traits, reference objects, trait state machines, coroutines, procedural macros, and preludes
- Part 4 (Lessons 36–40): Immutability, Cow, unsafe, overuse of unwrap, Vec, and clone, and overuse of Deref polymorphism and smart pointers

Course features
- The slides explain concepts and structure without including source code. You will look up the code directly by referring to the relevant pages and listing numbers in the book.
- Each lecture corresponds to the sections and code numbers in the book, so you can immediately find where to review.

Reference Before Enrolling
- This course accompanies 《Rust Clean Code》 (Jpub), and purchasing the book is required. Without the book, you cannot view the code listings.
- The book is not included in the price.

Why you need this course
Rust is a language where there can be a wide gap between code that compiles and code that is easy to read. The same problem can be solved using `clone`, references and lifetimes, trait objects, or generics. This course helps you establish criteria for when each choice is appropriate.

What this course does not cover
- An introduction to Rust syntax and the basics of ownership
- How to use asynchronous runtimes or specific web frameworks
- The full source code (the relevant listings in the book are provided as a reference)

What you can do after completing the course
Once you finish the course, you can make evidence-based judgments in code reviews about whether something is “idiomatic Rust.” You can apply patterns such as builders and newtypes only where needed, and propose guidelines to your team for reducing the use of unsafe and unwrap.

Recommended for
these people

Who is this course right for?

  • A developer who knows Rust syntax but has no standard for writing “idiomatic Rust”

  • A developer stuck while translating patterns from C++ or other languages into Rust

  • A Rust developer looking to organize the design of a library or team codebase

Need to know before starting?

  • This assumes you have already learned the basics of Rust syntax (ownership, structs, enums, and traits).

Hello
This is devbull

Career Verified

170

Learners

15

Reviews

3

Answers

4.3

Rating

5

Courses

Rustacean & Pythonista

Curriculum

All

40 lectures ∙ (6hr 8min)

Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

devbull's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

25% off for new members

$12.00

25%

$22.00