fix errors in enum.md

This commit is contained in:
sunface
2022-03-01 18:58:36 +08:00
parent bda6040eab
commit 726ef682cb
8 changed files with 144 additions and 19 deletions

View File

@ -19,7 +19,7 @@
- [枚举](compound-types/enum.md)
- [流程控制](flow-control.md)
- [模式匹配 todo](pattern-match/intro.md)
- [match 和 if let](pattern-match/match-iflet.md)
- [match, matches! 和 if let](pattern-match/match-iflet.md)
- [解构 Option](pattern-match/option.md)
- [模式](pattern-match/patterns.md)
- [方法 Method todo](method.md)

View File

@ -48,7 +48,7 @@ fn main() {
}
```
🌟🌟🌟 枚举成员中的值可以使用模式匹配来获取
🌟🌟 枚举成员中的值可以使用模式匹配来获取
```rust,editable
// 仅填空,不要修改其它代码!
@ -63,14 +63,14 @@ fn main() {
let msg = Message::Move{x: 1, y: 1};
if let Message::Move{__} = msg {
assert_eq!(x, y);
assert_eq!(a, b);
} else {
panic!("不要让这行代码运行!");
}
panic!("不要让这行代码运行!");
}
```
🌟🌟🌟 使用枚举对类型进行同一化
🌟🌟 使用枚举对类型进行同一化
```rust,editable
@ -102,7 +102,7 @@ fn show_message(msg: Message) {
🌟🌟 Rust 中没有 `null`,我们通过 `Option<T>` 枚举来处理值为空的情况
```rust,editable
// 填空,不要修改其它代码!
// 填空让 `println` 输出,同时添加一些代码不要让最后一行的 `panic` 执行到
fn main() {
let five = Some(5);
let six = plus_one(five);
@ -110,8 +110,8 @@ fn main() {
if let __ = six {
println!("{}", n)
}
}
panic!("不要让这行代码运行!");
}

View File

@ -1,3 +1,2 @@
# Iterator
https://doc.rust-lang.org/stable/rust-by-example/flow_control/for.html#for-and-iterators