Rust in Depth cover

Rust in Depth

Rating 4.1
Word count
337K words
Chapters
40
ISBN
9787111606420

Tags

Summary

Written by Fan Changchun, a contributor to the Rust open-source project, Rust in Depth is divided into five parts. Part One covers Rust basics: variables and types, statements and expressions, functions, traits, arrays and strings, pattern destructuring, the type system, and macros. Part Two explores Rust's unique memory management mechanism: memory management fundamentals, ownership and move semantics, borrowing and lifetimes, borrow checking, NLL, interior mutability, dereferencing, leaks, panics, unsafe code, and an analysis of the Vec source code. Part Three discusses abstraction capabilities: generics, closures, dynamic and static dispatch, containers and iterators, generators, and an overview of the standard library. Part Four addresses concurrency and thread safety: thread safety, Send and Sync, state sharing, channels, and third-party parallel development libraries. Part Five introduces practical engineering facilities: projects and modules, error handling, FFI, documentation and testing, plus a glossary. The author's focus is not to enumerate language features but to explain the ideas behind the language design, helping readers thoroughly understand Rust's advanced features such as algebraic type systems, lifetimes, borrow checking, interior mutability, generics, closures, and iterators. At about 337,000 Chinese characters, the book is suitable for students, software engineers, and researchers, and is also beneficial for understanding other systems programming languages such as C++.

Editor's review

本书是早期中文Rust原创图书中的代表作,作者范长春是中科院自动化所博士、Rust开源项目贡献者,也曾在微软工作,后来参与Coverity静态检查工具的开发,因此书中对编译器、类型系统和借用检查的讲解带有明显的“实现视角”。与同时期偏手册式的语言教程相比,本书真正的价值在于第二部分的“内存安全”:它把所有权与移动语义、借用与生命周期、借用检查、NLL、内部可变性、Unsafe以及Vec源码分析串成一条线,让读者明白这些规则为何存在、编译器在检查什么。第三、四部分关于泛型、闭包、trait对象、迭代器、生成器与Send/Sync、线程安全的讨论,也常被读者拿来作为理解并发模型的参考。书的结构清晰、有五大部分35章,篇幅约337千字,门槛适中但需要动手跟代码。需要注意,本书成书于2018年,尚未覆盖Rust 2018 edition之后的大量新特性(如async/await、新模块系统细节),读时建议对照官方《The Rust Programming Language》与最新文档补齐。

Who it's for

A good fit for

  • 有C/C++、Python或Java基础、想系统入门Rust的开发者
  • 已经会写Rust但被借用检查、生命周期反复卡住的程序员
  • 需要理解Rust内存模型与并发安全原理的系统编程工程师
  • 讲授程序设计语言或系统编程课程的教师与研究人员

Not a good fit for

  • 完全零编程经验的初学者,书中很少讲基础编程概念
  • 只想找大量项目实战案例、照着做一个完整项目的读者
  • 需要覆盖async/await等最新Rust特性的读者

Reading tips

  1. 按五大部分顺序阅读,重点放在第二部分内存安全,可反复读两遍并动手改代码
  2. 读每章语法点时同步写小例子,用cargo check观察借用检查器报错信息的变化
  3. 结合官方《The Rust Programming Language》和Rust标准库文档对照阅读,弥补版本差异
  4. 第20章Vec源码与第19章Unsafe较硬,第一遍可略读,完成小项目后再回头精读

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Preface
  2. Part One Fundamentals
  3. Chapter 1 First Meeting
  4. Chapter 2 Variables and Types
  5. Chapter 3 Statements and Expressions
  6. Chapter 4 Functions
  7. Chapter 5 Traits
  8. Chapter 6 Arrays and Strings
  9. Chapter 7 Pattern Destructuring
  10. Chapter 8 Inside the Type System
  11. Chapter 9 Macros
  12. Part Two Memory Safety
  13. Chapter 10 Memory Management Fundamentals
  14. Chapter 11 Ownership and Move Semantics
  15. Chapter 12 Borrowing and Lifetimes
  16. Chapter 13 Borrow Checking
  17. Chapter 14 NLL (Non-Lexical Lifetime)
  18. Chapter 15 Interior Mutability
  19. Chapter 16 Dereferencing
  20. Chapter 17 Leaks
  21. Chapter 18 Panic
  22. Chapter 19 Unsafe
  23. Chapter 20 Vec Source Code Analysis
  24. Part Three Advanced Abstraction
  25. Chapter 21 Generics
  26. Chapter 22 Closures
  27. Chapter 23 Dynamic and Static Dispatch
  28. Chapter 24 Containers and Iterators
  29. Chapter 25 Generators
  30. Chapter 26 Introduction to the Standard Library
  31. Part Four Thread Safety
  32. Chapter 27 Thread Safety
  33. Chapter 28 Send and Sync in Detail
  34. Chapter 29 State Sharing
  35. Chapter 30 Channels
  36. Chapter 31 Third-Party Parallel Development Libraries
  37. Part Five Practical Facilities
  38. Chapter 32 Projects and Modules
  39. Chapter 33 Error Handling
  40. Chapter 34 FFI

FAQ

这本书适合完全没有编程基础的人吗?
不适合。书中几乎不解释变量、循环、函数等通用编程概念,默认读者有C/C++、Java或Python基础。零基础读者建议先学一门主流语言,再回来读本书。
书的出版时间较早,现在读会不会过时?
本书2018年出版,语法示例基于Rust 1.2x版本,未覆盖async/await、Rust 2021 edition等新内容。但所有权、借用、生命周期、Send/Sync等核心机制至今未变,仍是很好的原理读物,只需配合官方文档补充新特性。
读完后能到什么水平?
能扎实理解Rust的类型系统、内存管理与并发安全机制,看懂常见的借用检查报错并正确修复。但工程能力还需通过实际项目、宏与异步编程的专项练习来补足。
需要边读边敲代码吗?
强烈建议。本书讲的是编译器行为与设计思想,只看文字容易产生“懂了”的错觉;用cargo新建工程复现示例并故意制造报错,理解会更牢固。
书里有没有配套源码或习题?
书中正文穿插大量可运行的代码片段,但没有系统性习题册;读者可自行搭建cargo工程整理代码,并参考作者在网络上发表的Rust技术文章。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category