-
Book Overview & Buying
-
Table Of Contents
Design Patterns and Best Practices in Rust
By :
In this chapter, we'll explore structural design patterns in Rust and how they help us organize components into larger, more capable systems. In Chapter 5, Creational Patterns: Making Things, we used creational patterns to establish clean ways of constructing our calculator's objects: builders for configuration, factories for token creation, and singletons for shared state. Structural patterns pick up where creational patterns leave off. Once we have well-constructed objects, structural patterns define how those objects connect, wrap, and compose into complex structures while maintaining flexibility and type safety.
We'll see how Rust's features influence our approach to these patterns in significant ways. Ownership and borrowing eliminate entire categories of problems that traditional structural patterns were designed to solve. Smart pointers like Box, Rc, and Arc provide built-in structural...