4 Introductory patterns
Now we’re ready to dive into some more concrete patterns. We begin by reviewing some elementary topics: RAII, passing values, constructors, and visibility. Then we’ll move on to slightly more complex subjects: error handling and global variables. Although the chapter discusses many topics, it focuses on bite-size patterns, which we’ll use a lot.
This chapter also introduces crates, which are Rust libraries built by the community. The Rust language is built on crates, which are crucial parts of Rust programming; you won’t get far without using them. Although it’s possible to go full not-invented-here syndrome and eschew crates, I don’t recommend this approach. Even the largest, best-funded organizations rely heavily on open source software to build their stacks to varying degrees.
You’ll quickly find when working with Rust that the standard library is somewhat bare and doesn’t include many of the features you might expect from a modern language. These limits are by design; the Rust team chose to keep the standard library minimal and instead rely on crates to provide additional functionality. This approach has several benefits: