Concepts

The first two chapters of this book covered Rust's types and traits, which helps provide the vocabulary needed to work with some of the concepts involved in writing Rust codeā€”the subject of this chapter.

The borrow checker and lifetime checks are central to what makes Rust unique; they are also a common stumbling block for newcomers to Rust and so are the focus of the first two Items in this chapter.

The other Items in this chapter cover concepts that are easier to grasp but are nevertheless a bit different from writing code in other languages. This includes the following:

  • Advice on Rust's unsafe mode and how to avoid it (Item 16)
  • Good news and bad news about writing multithreaded code in Rust (Item 17)
  • Advice on avoiding runtime aborts (Item 18)
  • Information about Rust's approach to reflection (Item 19)
  • Advice on balancing optimization against maintainability (Item 20)

It's a good idea to try to align your code with the consequences of these concepts. It's possible to re-create (some of) the behavior of C/C++ in Rust, but why bother to use Rust if you do?