Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade AutoCorrect v2.9.0 and fix docs. #758

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/autocorrect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
fetch-depth: 1

- name: Lint
uses: huacnlee/autocorrect-action@v2.5.8
uses: huacnlee/autocorrect-action@v2.9.0
8 changes: 4 additions & 4 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
- [Cargo 自定义扩展命令](ch14-05-extending-cargo.md)

- [智能指针](ch15-00-smart-pointers.md)
- [使用`Box<T>` 指向堆上数据](ch15-01-box.md)
- [使用`Deref` Trait 将智能指针当作常规引用处理](ch15-02-deref.md)
- [使用`Drop` Trait 运行清理代码](ch15-03-drop.md)
- [使用 `Box<T>` 指向堆上数据](ch15-01-box.md)
- [使用 `Deref` Trait 将智能指针当作常规引用处理](ch15-02-deref.md)
- [使用 `Drop` Trait 运行清理代码](ch15-03-drop.md)
- [`Rc<T>` 引用计数智能指针](ch15-04-rc.md)
- [`RefCell<T>` 与内部可变性模式](ch15-05-interior-mutability.md)
- [引用循环会导致内存泄漏](ch15-06-reference-cycles.md)
Expand All @@ -99,7 +99,7 @@
- [使用线程同时地运行代码](ch16-01-threads.md)
- [使用消息传递在线程间通信](ch16-02-message-passing.md)
- [共享状态并发](ch16-03-shared-state.md)
- [使用`Sync` 与 `Send` Traits 的可扩展并发:](ch16-04-extensible-concurrency-sync-and-send.md)
- [使用 `Sync` 与 `Send` Traits 的可扩展并发:](ch16-04-extensible-concurrency-sync-and-send.md)

- [Rust 的面向对象编程特性](ch17-00-oop.md)
- [面向对象语言的特点](ch17-01-what-is-oo.md)
Expand Down
8 changes: 4 additions & 4 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
- [Cargo 自定义扩展命令](ch14-05-extending-cargo.md)

- [智能指针](ch15-00-smart-pointers.md)
- [使用`Box<T>` 指向堆上数据](ch15-01-box.md)
- [使用`Deref` Trait 将智能指针当作常规引用处理](ch15-02-deref.md)
- [使用`Drop` Trait 运行清理代码](ch15-03-drop.md)
- [使用 `Box<T>` 指向堆上数据](ch15-01-box.md)
- [使用 `Deref` Trait 将智能指针当作常规引用处理](ch15-02-deref.md)
- [使用 `Drop` Trait 运行清理代码](ch15-03-drop.md)
- [`Rc<T>` 引用计数智能指针](ch15-04-rc.md)
- [`RefCell<T>` 与内部可变性模式](ch15-05-interior-mutability.md)
- [引用循环会导致内存泄漏](ch15-06-reference-cycles.md)
Expand All @@ -99,7 +99,7 @@
- [使用线程同时地运行代码](ch16-01-threads.md)
- [使用消息传递在线程间通信](ch16-02-message-passing.md)
- [共享状态并发](ch16-03-shared-state.md)
- [使用`Sync` 与 `Send` Traits 的可扩展并发](ch16-04-extensible-concurrency-sync-and-send.md)
- [使用 `Sync` 与 `Send` Traits 的可扩展并发](ch16-04-extensible-concurrency-sync-and-send.md)

- [Rust 的面向对象编程特性](ch17-00-oop.md)
- [面向对象语言的特点](ch17-01-what-is-oo.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

回到示例 7-1,假设我们希望调用 `add_to_waitlist` 函数。还是同样的问题,`add_to_waitlist` 函数的路径是什么?在示例 7-3 中删除了一些模块和函数。

我们在 crate 根定义了一个新函数 `eat_at_restaurant`,并在其中展示调用 `add_to_waitlist` 函数的两种方法。`eat_at_restaurant` 函数是我们 crate 库的一个公共 API,所以我们使用 `pub` 关键字来标记它。在 [“使用`pub`关键字暴露路径”][pub] 一节,我们将详细介绍 `pub`。注意,这个例子无法编译通过,我们稍后会解释原因。
我们在 crate 根定义了一个新函数 `eat_at_restaurant`,并在其中展示调用 `add_to_waitlist` 函数的两种方法。`eat_at_restaurant` 函数是我们 crate 库的一个公共 API,所以我们使用 `pub` 关键字来标记它。在 [“使用 `pub` 关键字暴露路径”][pub] 一节,我们将详细介绍 `pub`。注意,这个例子无法编译通过,我们稍后会解释原因。

<span class="filename">文件名:src/lib.rs</span>

Expand Down
2 changes: 1 addition & 1 deletion src/ch17-01-what-is-oo.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{{#rustdoc_include ../listings/ch17-oop/listing-17-02/src/lib.rs:here}}
```

<span class="caption">示例 17-2: 在`AveragedCollection` 结构体上实现了`add`、`remove` 和 `average` 公有方法</span>
<span class="caption">示例 17-2: 在 `AveragedCollection` 结构体上实现了 `add`、`remove` 和 `average` 公有方法</span>

公有方法 `add`、`remove` 和 `average` 是修改 `AveragedCollection` 实例的唯一方式。当使用 `add` 方法把一个元素加入到 `list` 或者使用 `remove` 方法来删除时,这些方法的实现同时会调用私有的 `update_average` 方法来更新 `average` 字段。

Expand Down
2 changes: 1 addition & 1 deletion src/ch17-03-oo-design-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
{{#rustdoc_include ../listings/ch17-oop/listing-17-17/src/lib.rs:here}}
```

<span class="caption">示例 17-17: 更新 `Post` 的 `content` 方法来委托调用 `State` 的`content` 方法</span>
<span class="caption">示例 17-17: 更新 `Post` 的 `content` 方法来委托调用 `State` 的 `content` 方法</span>

因为目标是将所有像这样的规则保持在实现了 `State` 的结构体中,我们将调用 `state` 中的值的 `content` 方法并传递博文实例(也就是 `self`)作为参数。接着返回 `state` 值的 `content` 方法的返回值。

Expand Down