This chapter covers
- The todo! macro to make the compiler quiet for a while
- Type aliases to create different names but not new types
- The Cow enum, which allows you to choose to borrow or own data however you want
- Rc, which allows shared instead of unique ownership
- Using multiple threads to run many things at the same time
You’re getting pretty good at Rust by now, so it’s time to take a look at some more advanced types. This chapter doesn’t really have a single theme. Instead, we’ll look in turn at some advanced subjects: Cow, type aliases, Rc, and multiple threads. Understanding how multiple threads work is probably the hardest part of this chapter. The famous Cow type (yes, that’s its real name) is a little bit tricky, too. You’ll probably like the Rc (reference counter) type as it gives you a bit of extra flexibility when it comes to Rust’s ownership rules.
use std::cell::{Cell, RefCell};