From 54cc7c83c50124e0f8043c256695451b99699fc1 Mon Sep 17 00:00:00 2001 From: Orefa Date: Mon, 21 Sep 2020 22:26:22 +0800 Subject: [PATCH] remove > --- src/ch15-01-box.md | 2 +- src/ch15-02-deref.md | 2 +- src/ch15-03-drop.md | 2 +- src/ch15-04-rc.md | 2 +- src/ch15-05-interior-mutability.md | 2 +- src/ch15-06-reference-cycles.md | 2 +- src/ch16-00-concurrency.md | 2 +- src/ch16-01-threads.md | 2 +- src/ch16-02-message-passing.md | 2 +- src/ch16-03-shared-state.md | 2 +- src/ch16-04-extensible-concurrency-sync-and-send.md | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ch15-01-box.md b/src/ch15-01-box.md index 9e55cde..44996fd 100644 --- a/src/ch15-01-box.md +++ b/src/ch15-01-box.md @@ -1,6 +1,6 @@ ## 使用`Box `指向堆上的数据 -> [ch15-01-box.md](https://github.com/rust-lang/book/blob/master/src/ch15-01-box.md) >
+> [ch15-01-box.md](https://github.com/rust-lang/book/blob/master/src/ch15-01-box.md)
> commit a203290c640a378453261948b3fee4c4c6eb3d0f 最简单直接的智能指针是 _box_,其类型是 `Box`。 box 允许你将一个值放在堆上而不是栈上。留在栈上的则是指向堆数据的指针。如果你想回顾一下栈与堆的区别请参考第四章。 diff --git a/src/ch15-02-deref.md b/src/ch15-02-deref.md index 960dae4..2458b0c 100644 --- a/src/ch15-02-deref.md +++ b/src/ch15-02-deref.md @@ -1,6 +1,6 @@ ## 通过 `Deref` trait 将智能指针当作常规引用处理 -> [ch15-02-deref.md](https://github.com/rust-lang/book/blob/master/src/ch15-02-deref.md) >
+> [ch15-02-deref.md](https://github.com/rust-lang/book/blob/master/src/ch15-02-deref.md)
> commit 44f1b71c117b0dcec7805eced0b95405167092f6 实现 `Deref` trait 允许我们重载 **解引用运算符**(_dereference operator_)`*`(与乘法运算符或通配符相区别)。通过这种方式实现 `Deref` trait 的智能指针可以被当作常规引用来对待,可以编写操作引用的代码并用于智能指针。 diff --git a/src/ch15-03-drop.md b/src/ch15-03-drop.md index d0930b5..249f712 100644 --- a/src/ch15-03-drop.md +++ b/src/ch15-03-drop.md @@ -1,6 +1,6 @@ ## 使用 `Drop` Trait 运行清理代码 -> [ch15-03-drop.md](https://github.com/rust-lang/book/blob/master/src/ch15-03-drop.md) >
+> [ch15-03-drop.md](https://github.com/rust-lang/book/blob/master/src/ch15-03-drop.md)
> commit 57adb83f69a69e20862d9e107b2a8bab95169b4c 对于智能指针模式来说第二个重要的 trait 是 `Drop`,其允许我们在值要离开作用域时执行一些代码。可以为任何类型提供 `Drop` trait 的实现,同时所指定的代码被用于释放类似于文件或网络连接的资源。我们在智能指针上下文中讨论 `Drop` 是因为其功能几乎总是用于实现智能指针。例如,`Box` 自定义了 `Drop` 用来释放 box 所指向的堆空间。 diff --git a/src/ch15-04-rc.md b/src/ch15-04-rc.md index feea295..3a49904 100644 --- a/src/ch15-04-rc.md +++ b/src/ch15-04-rc.md @@ -1,6 +1,6 @@ ## `Rc` 引用计数智能指针 -> [ch15-04-rc.md](https://github.com/rust-lang/book/blob/master/src/ch15-04-rc.md) >
+> [ch15-04-rc.md](https://github.com/rust-lang/book/blob/master/src/ch15-04-rc.md)
> commit 6f292c8439927b4c5b870dd4afd2bfc52cc4eccc 大部分情况下所有权是非常明确的:可以准确地知道哪个变量拥有某个值。然而,有些情况单个值可能会有多个所有者。例如,在图数据结构中,多个边可能指向相同的节点,而这个节点从概念上讲为所有指向它的边所拥有。节点直到没有任何边指向它之前都不应该被清理。 diff --git a/src/ch15-05-interior-mutability.md b/src/ch15-05-interior-mutability.md index 85be0b5..b37c05a 100644 --- a/src/ch15-05-interior-mutability.md +++ b/src/ch15-05-interior-mutability.md @@ -1,6 +1,6 @@ ## `RefCell` 和内部可变性模式 -> [ch15-05-interior-mutability.md](https://github.com/rust-lang/book/blob/master/src/ch15-05-interior-mutability.md) >
+> [ch15-05-interior-mutability.md](https://github.com/rust-lang/book/blob/master/src/ch15-05-interior-mutability.md)
> commit 26565efc3f62d9dacb7c2c6d0f5974360e459493 **内部可变性**(_Interior mutability_)是 Rust 中的一个设计模式,它允许你即使在有不可变引用时也可以改变数据,这通常是借用规则所不允许的。为了改变数据,该模式在数据结构中使用 `unsafe` 代码来模糊 Rust 通常的可变性和借用规则。我们还未讲到不安全代码;第十九章会学习它们。当可以确保代码在运行时会遵守借用规则,即使编译器不能保证的情况,可以选择使用那些运用内部可变性模式的类型。所涉及的 `unsafe` 代码将被封装进安全的 API 中,而外部类型仍然是不可变的。 diff --git a/src/ch15-06-reference-cycles.md b/src/ch15-06-reference-cycles.md index 494661a..af3ed8f 100644 --- a/src/ch15-06-reference-cycles.md +++ b/src/ch15-06-reference-cycles.md @@ -1,6 +1,6 @@ ## 引用循环与内存泄漏 -> [ch15-06-reference-cycles.md](https://github.com/rust-lang/book/blob/master/src/ch15-06-reference-cycles.md) >
+> [ch15-06-reference-cycles.md](https://github.com/rust-lang/book/blob/master/src/ch15-06-reference-cycles.md)
> commit f617d58c1a88dd2912739a041fd4725d127bf9fb Rust 的内存安全性保证使其难以意外地制造永远也不会被清理的内存(被称为 **内存泄漏**(_memory leak_)),但并不是不可能。与在编译时拒绝数据竞争不同, Rust 并不保证完全地避免内存泄漏,这意味着内存泄漏在 Rust 被认为是内存安全的。这一点可以通过 `Rc` 和 `RefCell` 看出:创建引用循环的可能性是存在的。这会造成内存泄漏,因为每一项的引用计数永远也到不了 0,其值也永远不会被丢弃。 diff --git a/src/ch16-00-concurrency.md b/src/ch16-00-concurrency.md index 152934f..cf02fbd 100644 --- a/src/ch16-00-concurrency.md +++ b/src/ch16-00-concurrency.md @@ -1,6 +1,6 @@ # 无畏并发 -> [ch16-00-concurrency.md](https://github.com/rust-lang/book/blob/master/src/ch16-00-concurrency.md) >
+> [ch16-00-concurrency.md](https://github.com/rust-lang/book/blob/master/src/ch16-00-concurrency.md)
> commit 1fedfc4b96c2017f64ecfcf41a0a07e2e815f24f 安全且高效的处理并发编程是 Rust 的另一个主要目标。**并发编程**(_Concurrent programming_),代表程序的不同部分相互独立的执行,而 **并行编程**(_parallel programming_)代表程序不同部分于同时执行,这两个概念随着计算机越来越多的利用多处理器的优势时显得愈发重要。由于历史原因,在此类上下文中编程一直是困难且容易出错的:Rust 希望能改变这一点。 diff --git a/src/ch16-01-threads.md b/src/ch16-01-threads.md index c253055..e3c184a 100644 --- a/src/ch16-01-threads.md +++ b/src/ch16-01-threads.md @@ -1,6 +1,6 @@ ## 使用线程同时运行代码 -> [ch16-01-threads.md](https://github.com/rust-lang/book/blob/master/src/ch16-01-threads.md) >
+> [ch16-01-threads.md](https://github.com/rust-lang/book/blob/master/src/ch16-01-threads.md)
> commit 1fedfc4b96c2017f64ecfcf41a0a07e2e815f24f 在大部分现代操作系统中,已执行程序的代码在一个 **进程**(_process_)中运行,操作系统则负责管理多个进程。在程序内部,也可以拥有多个同时运行的独立部分。运行这些独立部分的功能被称为 **线程**(_threads_)。 diff --git a/src/ch16-02-message-passing.md b/src/ch16-02-message-passing.md index 1525486..6069ac7 100644 --- a/src/ch16-02-message-passing.md +++ b/src/ch16-02-message-passing.md @@ -1,6 +1,6 @@ ## 使用消息传递在线程间传送数据 -> [ch16-02-message-passing.md](https://github.com/rust-lang/book/blob/master/src/ch16-02-message-passing.md) >
+> [ch16-02-message-passing.md](https://github.com/rust-lang/book/blob/master/src/ch16-02-message-passing.md)
> commit 26565efc3f62d9dacb7c2c6d0f5974360e459493 一个日益流行的确保安全并发的方式是 **消息传递**(_message passing_),这里线程或 actor 通过发送包含数据的消息来相互沟通。这个思想来源于 [Go 编程语言文档中](http://golang.org/doc/effective_go.html) 的口号:“不要通过共享内存来通讯;而是通过通讯来共享内存。”(“Do not communicate by sharing memory; instead, share memory by communicating.”) diff --git a/src/ch16-03-shared-state.md b/src/ch16-03-shared-state.md index a767e18..85703fe 100644 --- a/src/ch16-03-shared-state.md +++ b/src/ch16-03-shared-state.md @@ -1,6 +1,6 @@ ## 共享状态并发 -> [ch16-03-shared-state.md](https://github.com/rust-lang/book/blob/master/src/ch16-03-shared-state.md) >
+> [ch16-03-shared-state.md](https://github.com/rust-lang/book/blob/master/src/ch16-03-shared-state.md)
> commit ef072458f903775e91ea9e21356154bc57ee31da 虽然消息传递是一个很好的处理并发的方式,但并不是唯一一个。再一次思考一下 Go 编程语言文档中口号的这一部分:“不要通过共享内存来通讯”(“do not communicate by sharing memory.”): diff --git a/src/ch16-04-extensible-concurrency-sync-and-send.md b/src/ch16-04-extensible-concurrency-sync-and-send.md index 97fedde..c84fbfe 100644 --- a/src/ch16-04-extensible-concurrency-sync-and-send.md +++ b/src/ch16-04-extensible-concurrency-sync-and-send.md @@ -1,6 +1,6 @@ ## 使用 `Sync` 和 `Send` trait 的可扩展并发 -> [ch16-04-extensible-concurrency-sync-and-send.md](https://github.com/rust-lang/book/blob/master/src/ch16-04-extensible-concurrency-sync-and-send.md) >
+> [ch16-04-extensible-concurrency-sync-and-send.md](https://github.com/rust-lang/book/blob/master/src/ch16-04-extensible-concurrency-sync-and-send.md)
> commit 426f3e4ec17e539ae9905ba559411169d303a031 Rust 的并发模型中一个有趣的方面是:语言本身对并发知之 **甚少**。我们之前讨论的几乎所有内容,都属于标准库,而不是语言本身的内容。由于不需要语言提供并发相关的基础设施,并发方案不受标准库或语言所限:我们可以编写自己的或使用别人编写的并发功能。