So, you're coming from C++ and want to write Rust? Great!

You have questions? We have answers.

This book is a collection of frequently asked questions for those arriving from existing C++ codebases. It guides you on how to adapt your C++ thinking to the new facilities available in Rust. It should help you if you're coming from other object-oriented languages such as Java too.

Although it's structured as questions and answers, it can also be read front-to-back, to give you hints about how to adapt your C++/Java thinking to a more idiomatically Rusty approach.

It does not aim to teach you Rust - there are many better resources. It doesn't aim to talk about Rust idioms in general - there are great existing guides for that. This guide is specifically about transitioning from some other traditionally OO language. If you're coming from such a language, you'll have questions about how to achieve the same outcomes in idiomatic Rust. That's what this guide is for.


The guide starts with idioms at the small scale - answering questions about how you'd write a few lines of code - and moves towards ever larger patterns - answering questions about how you'd structure your whole codebase.


The following awesome people helped write the answers here, and they're sometimes quoted using the abbreviations given.

Thanks to Alyssa Haroldsen (@kupiakos) (AH), Augie Fackler (AF), David Tolnay (@davidtolnay) (DT), Łukasz Anforowicz (LA), Manish Goregaokar (@ManishEarth) (MG), Mike Forster (MF), Miguel Young de la Sota (@DrawsMiguel) (MY), and Tyler Mandry (@tmandry) (TM).

Their views have been edited and collated by Adrian Taylor (@adehohum), and Martin Brænne. Any errors or misrepresentations are ours.

Licensed under either of Apache License, Version 2.0 or MIT license at your option.