liveBook · Manning

Chapter 1: Some basics

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

The chapter introduction previews the basics and explains that even simple Rust types involve choices, while the compiler strictly checks programs before they run.

After this chapter you will be able to

Section by section

Introduction

The chapter introduction previews the basics and explains that even simple Rust types involve choices, while the compiler strictly checks programs before they run.

Key terms: bits and bytes, simple types, integers, compiler, strict

1.1 Introducing Rust

Introduces Rust’s appeal and explains why its compiler makes learning feel demanding but helpful.

Key terms: speed and control, memory safety, rich type system, compiler, hangover first, types, possible errors

1.1.1 A pep talk

The section reassures beginners that Rust’s difficult learning period gives way to confidence because the compiler helps identify problems when code changes.

Key terms: frustrating days, doing a lot of the thinking for you, compile, compiler, contributing, refactoring

1.1.2 Rust is like a critical spouse

The section explains how Rust’s strict but helpful compiler catches problems before a program runs, guides corrections, and warns about unused code.

Key terms: compile time, run time, debug, Rust compiler, suggestions, warning, variable

1.2 Comments

This section explains how Rust comments are written and used, and briefly introduces named variables through an example.

Key terms: comment, //, /* */, compiler, doc comment, documentation comment, ///, variable, let, some_number

1.3 Primitive types: Integers, characters, and strings

This section explains Rust’s basic integer and character types, how casts behave, and why a string’s byte length can differ from its character count.

Key terms: integer, signed integer, unsigned integer, bits, i8, u8, binary, bit, isize, usize

1.4 Type inference

Explains how Rust infers variable types and how numeric types and literals can be written explicitly.

Key terms: type inference, compiler, i32, type, i128, _, integer, float

1.5 Floats

Introduces Rust’s floating-point types, explains why mixing f32 and f64 causes a type error, and shows two ways to make the types compatible.

Key terms: float, f32, f64, bits, expected (type), found (type), cast, as, type declarations

1.6 “Hello, World!” and printing

This section uses a Hello, World! program to explain basic function syntax, code blocks, printing, return values, and when Rust frees variable memory.

Key terms: fn, main(), argument, type, code block, lifetime, {}, println!, semicolon, ->

1.7 Declaring variables and code blocks

The section introduces variable declarations, two ways to print variables, and how code blocks affect variable scope and returned values.

Key terms: let, variable, println!, {}, code block, lifetime, my_number, return value, semicolon, ()

1.8 Display and Debug

Explains Rust’s Display and Debug printing formats, how compiler errors can point to the right format, and how print! differs from println!.

Key terms: Display, Debug, pretty printing, {}, {:?}, {:#?}, trait, compiler, print!, println!

1.9 Smallest and largest numbers

This section shows how to refer to a numeric type’s smallest and largest values using MIN and MAX.

Key terms: MIN, MAX, consts, ::

1.10 Mutability (changing)

This section explains that Rust variables are immutable by default and that mut permits changing a value but not its type.

Key terms: let, immutable, let mut, mut, type

1.11 Shadowing

This section explains how Rust shadowing creates a new variable with an existing name, how scope affects which variable is visible, and why shadowing can be useful.

Key terms: shadowing, let binding, mutability, scope block, mutable variable, float

1.12 Summary

Where this is used later

Concepts explained in this chapter

Chapter 2: Memory, variables, and ownership →

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.