2 Rust’s basic building blocks

This chapter covers

  • Exploring the core Rust patterns
  • Diving into Rust generics
  • Exploring traits
  • Combining generics and traits
  • Deriving traits automatically

In this chapter, I’ll introduce and discuss some of Rust’s most important abstractions and features, which I call building blocks and which serve as the foundation of nearly all design patterns in Rust. Reviewing and understanding these building blocks before diving deeper into other patterns is crucial. For some readers, this chapter may appear to be a review of language basics; it sets the stage for more advanced topics, however, so I recommend that you don’t skip it.

We’ll begin by discussing generics and traits in Rust. They are the core building ...

Get Idiomatic Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.