Too Many Linked Lists
150 pages
English
PDF
4.5

Too Many Linked Lists

Too Many Linked Lists

Author:

Year:

Summary:

Introduction

The book "Too Many Linked Lists" by Alexis Beingessner is not just another guide to the Rust language. It is a unique, deep, and at times provocative textbook that forces the reader to truly understand how memory, ownership, and unsafe code work in Rust. Released in 2021, the book, about 150 pages long, has become a cult classic among Rust developers who want to move from writing safe code to working with raw pointers and manual memory management.

The author is a well-known Rust community developer who has worked on the Rust standard library and contributed to projects like Servo. His style is lively, humorous, and without unnecessary embellishments. The book is available for free online, but for the educational site PythonLib, we consider it a valuable resource for anyone wanting to delve deeper into systems programming.

What is this book about?

The title speaks for itself: the book is dedicated to implementing various types of linked lists in Rust. But not simple ones—those that require the use of unsafe Rust: raw pointers, manual dereferencing, and memory management. In total, the book covers six different implementations of singly and doubly linked lists, each revealing a specific aspect of working with memory.

Starting with a simple stack based on Box, the author gradually complicates the examples, moving on to lists using raw pointers, caching, and even lists that use "lazy" memory allocation. Each chapter is a separate challenge that forces the reader to rethink how borrowing, lifetimes, and safety work.

Who is this book for?

The book is intended for programmers already familiar with the basics of Rust. If you have just started learning Rust and are not yet confident with the concepts of ownership, borrowing, and lifetimes, this book may seem difficult. However, for those who have mastered the basic syntax and want to understand how Rust works "under the hood," this is the ideal next step.

The book will also be useful for C/C++ developers who want to see how Rust solves memory management problems and are ready to dive into the unsafe world. And, of course, it is a must-read for anyone planning to write Rust libraries that work with low-level data structures.

What will the reader learn?

After reading the book, you will be able to:

  • Understand when and why unsafe code is needed — and how to minimize risks when using it.
  • Implement a singly and doubly linked list from scratch using raw pointers.
  • Master working with Pin and Unpin — mechanisms that guarantee the stability of object addresses in memory.
  • Learn to write safe wrappers around unsafe code so as not to violate Rust's guarantees.
  • Understand how allocators work and how to create your own memory allocation strategies.
  • Learn about typical errors when working with pointers: dangling pointers, double free, data races.

Strengths of the book

The first thing that stands out is the writing style. Alexis writes with humor, often addresses the reader, and shares his own experience and mistakes. This is not a dry textbook, but a lively dialogue. The second strength is the gradual increase in complexity. Each new chapter builds on the previous one, and you never feel like you are being thrown into the deep end.

The third is the practical focus. There are no abstract examples in the book; every piece of code can be run and tested. The author also pays attention to testing and debugging unsafe code, which is extremely important in real-world development. Finally, the book is free and available in a web version, making it accessible to everyone.

The only downside is the book

Recommendations