35 Specific Ways to Improve Your Rust Code
David Drysdale

#Rust
#C++
Rust's popularity is growing, due in part to features like memory safety, type safety, and thread safety. But these same elements can also make learning Rust a challenge, even for experienced programmers. This practical guide helps you make the transition to writing idiomatic Rust—while also making full use of Rust's type system, safety guarantees, and burgeoning ecosystem.
If you're a software engineer who has experience with an existing compiled language, or if you've struggled to convert a basic understanding of Rust syntax into working programs, this book is for you. By focusing on the conceptual differences between Rust and other compiled languages, and by providing specific recommendations that programmers can easily follow, Effective Rust will soon have you writing fluent Rust, not just badly translated C++.
Table of Contents
Chapter 1. Types
Chapter 2. Traits
Chapter 3. Concepts
Chapter 4. Dependencies
Chapter 5. Tooling
Chapter 6. Beyond Standard Rust
Who This Book Is For
This book tries to help with these areas where programmers struggle, even if they already have experience with an existing compiled language like C++. As such—and in common with other Effective {Language} books—this book is intended to be the second book that a newcomer to Rust might need, after they have already encountered the basics elsewhere—for example, in the The Rust Programming Language (Steve Klabnik and Carol Nichols, No Starch Press) or in Programming Rust (Jim Blandy et al., O’Reilly).
However, Rust’s safety leads to a slightly different slant to the Items here, particularly when compared to Scott Meyers’ original Effective C++ series. The C++ language was (and is) full of footguns, so Effective C++ focused on a collection of advice that had been learned from real world experience of creating software in C++. Significantly, it contained guidelines not rules, because guidelines have exceptions—providing the detailed rationale for a guideline allows a reader to decide for themselves whether their particular scenario warranted breaking the rule.
The general style of giving advice together with the reasons for that advice is preserved here. However, since Rust is remarkably free of footguns, the Items here concentrate more on the concepts that are new with Rust. Many Items have titles like "Understand…" and "Familiarize yourself with…“, and help on the journey towards writing fluent, idiomatic Rust.
Rust’s safety also leads to a complete absence of Items titled "Never…“. If you really should never do something, the compiler will generally prevent you from doing it.
"Effective Rust is an excellent collection of real-world Rust knowledge beyond the basics. The advice in this book will help you become a confident and well-rounded Rustacean."
Carol Nichols, co-author of The Rust Programming Language
"Effective Rust dives deep into most of the recommendations I give people on how to improve their projects. It's a great resource to level up your Rust."
Pietro Albini, former member of the Rust Core Team
David Drysdale is a staff software engineer at Google and has been primarily working in Rust since 2019. He is the author of the Rust port of the Tink cryptography library and also led the project to replace Android’s hardware cryptography library (KeyMint) with a Rust version. He has extensive prior experience in C/C++ and Go and has previously worked on projects as diverse as the Linux kernel, networking control plane software, and mobile video conferencing apps.









