In this chapter, we explore the object-oriented features of Rust, which make it a really expressive language. With these features, we can apply well-known techniques from the object-oriented world, so that our programs can better model real-world situations.
We will cover the following topics:
- Associated functions on structs
- Methods on structs
- Using a constructor pattern
- Using a builder pattern
- Methods on tuples and enums
- Traits
- Using trait constraints
- Static and dynamic dispatch
- Built-in traits and operator overloading
- OOP in Rust
- Inheritance with traits
- Using the visitor pattern