Programming Rust (2/e)

Leonora F.S. Tindall, Jason Orendorff, Jim Blandy

出版时间

2021-05-04

ISBN

9781492052593

评分

★★★★★
书籍介绍
这不是一本带你从零认识 Rust 语言的书,而是一本专门治「学完就忘」的病。许多读者在啃完官方教程之后回头重读它,才真正体会到什么是「醍醐灌顶」——那些在官方书里一闪而过的所有权、生命周期、内存布局,在这里被拆解成一张图就能看懂的样子。它的独特之处在于叙事方式:不机械罗列语言特性,而是把「为什么 Rust 要这样设计」讲清楚,让有其它编程经验的读者能迅速建立起对内存模型的直觉。书中对 panic 的剖析尤为到位——它不是崩溃、不是未定义行为,而是一套被严格约束、保证安全的机制,配合「不要 panic」这一朴素准则,恰好点出了 Rust 安全哲学的全过程。适合把它放在手边当作长期参考书的人。
AI导读
核心看点
  • 深入解析Rust内存模型与所有权机制
  • 结合C++背景讲解系统级编程与性能控制
  • 清晰图示辅助理解并发、异步及类型系统
读者共识
  • 配图极佳,一图胜千言,直观易懂
  • 比官方文档更进阶,适合有经验读者
  • 讲解设计考量,被赞为最佳参考书之一
精彩摘录
  • "You've heard that Rust lets you write safe, fase, concurrent programs. This is the chapter where we show you how it's done. We'll cover three ways to use Rust threads: 1. Fork-join parallelism 2. Channels 3. Shared muatble state"
  • "A panic is not a crash. It’s not undefined behavior. It’s more like a RuntimeException in Java or a std::logic_error in C++. The behavior is well-defined; it just shouldn’t be happening. Panic is safe. It doesn’t violate any of Rust’s safety rules; even if you manage to panic in the middle of a stan"
  • "Stack unwinding is the default panic behavior, but there are two circumstances in which Rust does not try to unwind the stack. If a .drop() method triggers a second panic while Rust is still trying to clean up after the first, this is considered fatal. Rust stops unwinding and aborts the whole proce"
  • "以上情况的共同点是他们都由(不客气地说)程序员的错误所导致。而行之有效的的一条经验法则是:“不要 panic”。"
  • "None of these compromises are acceptable for Rust:the programmer should havecontroovervalueslifetimes,and the language should be safe.But this is a prettywell-explored area of language design.You can't make major improvements withoutsome fundamental changes. Rust breaks the deadlock in a surprising "
  • "另一方面,元组只允许用常量作为索引,比如t.4。不能通过写成t.i或t[i]的形式来获取第1个元素。"
  • "你会看到用来声明固定大小缓冲区的语法:[0u8;1024],它是一个1KB的缓冲区,用0填充。Rust没有任何能定义未初始化数组的写法。(一般来说,Rust会确保代码永远无法访问任何种类的未初始化值。)"
  • "&mut str类型确实存在,但它没什么用,因为对UTF-8的几乎所有操作都会更改其字节总长度,但切片不能重新分配其引用目标的缓冲区。事实上,&mut str上唯一可用的操作是make_ascii_uppercase和make_ascii_lowercase,根据定义,它们会就地修改文本并且只影响单字节字符。"
用户评论
比 The Rust Programming Language 要更进阶一些的书,内容组织方式也比简单罗列所有语言特性稍微更有趣一点,对于已经有其他编程经验的读者更友好一些。
和官方的The Rust Programming Language 一起食用味道更加;比官方的更加详细
如果 Rust 的书只看一本的话,我选这本(2021)
比官方的 The Rust Programming Language 要深入很多,让你真正上手 Rust!
傻瓜式教程。。没有比这本更简单、清晰、透彻的了。。比官方的那本更深入浅出
读了不下4本rust书籍,如果让我推荐一本rust书,那么我会推荐这本。比官方的还要详细,还要深入。
下载
收藏