From 68344de35771ae4effced06d4b881e9f6075e959 Mon Sep 17 00:00:00 2001 From: zongzi531 Date: Tue, 17 May 2022 17:25:59 +0800 Subject: [PATCH] fix: typo in ok-stack --- src/too-many-lists/ok-stack/iter.md | 10 ++++++---- src/too-many-lists/ok-stack/itermut.md | 1 + src/too-many-lists/ok-stack/peek.md | 4 ++-- src/too-many-lists/ok-stack/type-optimizing.md | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/too-many-lists/ok-stack/iter.md b/src/too-many-lists/ok-stack/iter.md index d8a8101e..17aa6d4a 100644 --- a/src/too-many-lists/ok-stack/iter.md +++ b/src/too-many-lists/ok-stack/iter.md @@ -217,7 +217,7 @@ impl<'a, T> Iterator for Iter<'a, T> { 现在,我们也许可以自信的编译下试试了: ```shell -cargo build +> cargo build error[E0308]: mismatched types --> src/second.rs:77:22 @@ -260,7 +260,8 @@ impl<'a, T> Iterator for Iter<'a, T> { ``` ```shell -cargo build +> cargo build + Compiling lists v0.1.0 (/Users/ABeingessner/dev/temp/lists) error[E0515]: cannot return reference to local data `*node` --> src/second.rs:77:43 @@ -314,7 +315,8 @@ impl<'a, T> Iterator for Iter<'a, T> { ``` ```shell -cargo build +> cargo build + Compiling lists v0.1.0 (/Users/ABeingessner/dev/temp/lists) error[E0308]: mismatched types --> src/second.rs:77:22 @@ -362,7 +364,7 @@ impl<'a, T> Iterator for Iter<'a, T> { ``` ```shell -cargo build +> cargo build ``` 🎉 🎉 🎉 diff --git a/src/too-many-lists/ok-stack/itermut.md b/src/too-many-lists/ok-stack/itermut.md index b1dc4706..4af8d1c5 100644 --- a/src/too-many-lists/ok-stack/itermut.md +++ b/src/too-many-lists/ok-stack/itermut.md @@ -58,6 +58,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { ```shell > cargo build + error[E0596]: cannot borrow `self.head` as mutable, as it is behind a `&` reference --> src/second.rs:95:25 | diff --git a/src/too-many-lists/ok-stack/peek.md b/src/too-many-lists/ok-stack/peek.md index a268b40f..a3adecdc 100644 --- a/src/too-many-lists/ok-stack/peek.md +++ b/src/too-many-lists/ok-stack/peek.md @@ -46,7 +46,7 @@ pub fn peek(&self) -> Option<&T> { ``` ```shell -cargo build +> cargo build Finished dev [unoptimized + debuginfo] target(s) in 0.32s ``` @@ -124,7 +124,7 @@ fn peek() { 这次我们直接匹配出来可变引用 `value`,然后对其修改即可。 ```shell -cargo test +> cargo test Running target/debug/lists-5c71138492ad4b4a diff --git a/src/too-many-lists/ok-stack/type-optimizing.md b/src/too-many-lists/ok-stack/type-optimizing.md index 05667807..aecbeca0 100644 --- a/src/too-many-lists/ok-stack/type-optimizing.md +++ b/src/too-many-lists/ok-stack/type-optimizing.md @@ -137,7 +137,7 @@ test second::test::basics ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured ``` -很棒,接下来让我们来解决目前链表最大的问题:只支持 i32 类型的元素值。 +很棒,接下来让我们来解决目前链表最大的问题:只支持 `i32` 类型的元素值。 ## 泛型 为了让链表支持任何类型的元素,泛型就是绕不过去的坎,首先将所有的类型定义修改为泛型实现: