Chapter 1, Starting with Rust, discusses the main reasons that led to the development of Rust. We compare Rust with other languages and indicate the areas for which it is most appropriate. Then, we guide you through installing all the necessary components for a Rust development environment. In particular, you will learn how to work with Cargo, Rust’s package manager.
Chapter 2, Using Variables and Types, looks at the basic structure of a Rust program. We discuss the primitive types, how to declare variables and whether they have to be typed, and the scope of variables. Immutability, one of the key cornerstones of Rust’s safety strategy is also illustrated. Then, we look at basic operations, how to do formatted printing, and the important difference between expressions and statements.
Chapter 3, Using Functions and Control Structures, shows how to define functions, and the different ways to influence program execution flow in Rust. We also take a look at attributes and how to do testing in Rust.
Chapter 4, Structuring Data and Matching Patterns, discusses the basic data types for programming, such as strings, vectors, slices, tuples, and enums. You will learn how to get input from the console and how to work with program arguments. Then we show you the powerful pattern matching that is possible in Rust and how values are extracted by destructuring patterns.
Chapter 5, Higher Order Functions and Error-Handling, explores the functional features of Rust. We see how data structures and functions can be defined in a generic way. Furthermore, you will learn how to work with Rust’s unique error-handling mechanism.
Chapter 6, Using Traits and OOP in Rust, explores the object-oriented features of Rust. We see how traits can be used to define behavior and to simulate inheritance in data structures. We also explore some common OOP patterns implemented in Rust, such as the visitor and the builder pattern.
Chapter 7, Ensuring Memory Safety and Pointers, exposes the borrow checker, Rust’s mechanism to ensure that only memory safe operations can occur during program execution. Different kinds of pointers are discussed in this chapter.
Chapter 8, Organizing Code and Macros, discusses the bigger code-organizing structures in Rust, such as modules and crates. It also touches upon how to build macros in order to generate code, thus saving time and effort.
Chapter 9, Concurrency – Coding for Multicore Execution, delves into Rust’s concurrency model based on threads and channels. We also discuss a safe strategy for working with shared mutable data.
Chapter 10, Programming at the Boundaries, looks at how Rust behaves in situations where we have to leave the safety boundaries, such as when interfacing with C or using raw pointers, and how Rust minimizes potential dangers when doing so.
Chapter 11, Exploring the Standard Library, gives us an overview of what is contained in Rust’s Standard Library with an emphasis on collections and the built-in macros. We also discuss how to let Rust work without standard library, for example, in very resource-constrained environments.
Chapter 12, The Ecosystem of Crates, covers how to work with crates built by other developers. We look at crates to work with files and databases, do web development, and develop graphics applications and games.