Rust by Example
320 pages
English
PDF
4.5

Rust by Example

Rust by Example

Author:

Year:

Summary:

Introduction

The book "Rust by Example" (original title Rust by Example) is a unique practical guide created by the Rust developer community. Unlike many academic textbooks, this book is built on the principle of "learning by doing." Each language concept is illustrated with small but complete code examples that can be immediately run and modified. The 2022 edition covers the stable version of Rust 1.60+ and includes 320 pages of concentrated information.

What the book is about

The book sequentially introduces the reader to the fundamentals of the Rust language, starting with syntax and ending with advanced topics such as ownership, borrowing, lifetimes, generics, traits, error handling, testing, asynchronous programming, and working with external libraries (crates). Each chapter contains several examples that increase in complexity as you progress. Special attention is paid to memory safety and concurrency — key advantages of Rust.

Who this book is for

The book is aimed at a wide audience:

  • Beginner programmers who want to learn Rust from scratch but already have a basic understanding of programming (variables, loops, functions).
  • Experienced C/C++ developers looking to master a modern, safe systems language.
  • Programmers in Python, Java, JavaScript who want to switch to Rust for improved performance and reliability.
  • Students and teachers looking for a practical textbook for courses on systems programming.

What the reader will learn

After studying the book, the reader will be able to:

  • Write safe and efficient code in Rust using the ownership and borrowing system.
  • Work with basic data types, strings, vectors, and hash maps.
  • Create custom types using structs and enums.
  • Use traits for polymorphism and code reuse.
  • Handle errors using Result and Option.
  • Write unit tests and documentation tests.
  • Work with closures, iterators, and collections.
  • Understand the basics of asynchronous programming with async/await.
  • Use the Cargo package manager for dependency management and project building.
  • Interact with C code via FFI (Foreign Function Interface).

Strengths

The main advantage of the book is its practical focus. Every example can be copied, run, and experimented with. This is especially important for Rust, where many concepts (such as lifetimes) are easier to understand through concrete examples than from theoretical descriptions. The book is written in simple language, without excessive academicism. The structure allows you to read chapters selectively, using the book as a reference. Additionally, the book is an open community project, so it is constantly updated and expanded.

Who it is recommended for

I highly recommend this book to anyone who wants to quickly and effectively learn Rust. It is ideal for self-study and can serve as an excellent supplement to the official book The Rust Programming Language. If you prefer to learn by doing and appreciate clear, working examples — "Rust by Example" will be your reliable companion.

Recommendations