liveBook · Manning

Chapter 3: More complex types

What you will learn in chapter 3 of Learn Rust in a Month of Lunches

The introduction distinguishes three collection types and defines control flow as changing how code runs depending on the situation.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction distinguishes three collection types and defines control flow as changing how code runs depending on the situation.

Key terms: arrays, vectors, tuples, collection types, control flow

3.1 Collection types

Introduces collections as a way to hold multiple ordered values and explains why arrays are a simple starting point.

Key terms: collections, values, order, arrays, vectors, tiny embedded devices, allocate memory

3.1.1 Arrays

This section explains how to create and use fixed-size Rust arrays, including repeated values, indexing, slices, and ways to identify array types.

Key terms: array, [type; number], [value; number], mut, byte buffers, compiler, method not found, b prefix, byte array, u8

3.1.2 Vectors

This section introduces vectors as resizable collections, explains their element types and common ways to create them, and shows how capacity affects allocation.

Key terms: array, vector, Vec, Vec<String>, <>, vec!, type inference, .push(), capacity, reallocation

3.1.3 Tuples

This section explains tuple values and types, the empty tuple as a function return value, and how to take tuple values apart with destructuring.

Key terms: tuple, empty tuple, unit type, semicolon, dot notation, destructuring, pattern, String, Copy type, _

3.2 Control flow

Introduces control flow as choosing what code does in different situations.

Key terms: control flow, condition

3.2.1 Basic control flow

This section introduces basic Rust control flow with if, else if, else, and combined conditions.

Key terms: if, condition, {}, ==, =, else if, else, &&, ||

3.2.2 Match statements

The section explains how Rust match statements select among patterns, require complete coverage and consistent arm types, and support guards and value binding.

Key terms: match, pattern, fat arrow, arm, _, wildcard, tuple, match guard, type, scope

3.2.3 Loops

This section explains how Rust’s loop, while, and for loops repeat work, how to stop them, and how a loop can produce a value.

Key terms: loop, break, tick, while loop, for loop, range, exclusive range, inclusive range, _, _number

3.3 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 2: Memory, variables, and ownership Chapter 4: Building your own types →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.