Rust's type system borrows a lot from the functional world with its structured types and traits. The type system is very strong: the types do not change under the hood and when something expects type X, you need to give it type X. Furthermore, the type system is static; nearly all of the type checks are done at runtime. These features give you very robust programs that rarely do the wrong thing during runtime, with the cost that writing the programs becomes a bit more constrained.
Rust's whole type system is not small, and we'll try to take a deep dive into it here. Expect lots of heavy material in this chapter, and be brave!
In this chapter, we will cover the following topics:
- String types
- Arrays and slices
- Generic types
- Traits and ...