From 0d33ca24bfc0979bc4b5c5b290e5f38db1aac845 Mon Sep 17 00:00:00 2001 From: sunface Date: Tue, 1 Mar 2022 20:12:55 +0800 Subject: [PATCH] fix typos --- src/SUMMARY.md | 3 +-- src/pattern-match/match-iflet.md | 8 ++++---- src/pattern-match/option.md | 1 - src/pattern-match/patterns.md | 22 ++++++++++++++++++++++ zh-CN/src/SUMMARY.md | 3 +-- zh-CN/src/pattern-match/match-iflet.md | 6 +++--- zh-CN/src/pattern-match/option.md | 1 - 7 files changed, 31 insertions(+), 13 deletions(-) delete mode 100644 src/pattern-match/option.md delete mode 100644 zh-CN/src/pattern-match/option.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 9ccac30..f6daf3e 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -18,9 +18,8 @@ - [Struct](compound-types/struct.md) - [Enum](compound-types/enum.md) - [Flow Control](flow-control.md) -- [Pattern Match todo](pattern-match/intro.md) +- [Pattern Match](pattern-match/intro.md) - [match, matches! and if let](pattern-match/match-iflet.md) - - [Option destructing](pattern-match/option.md) - [Patterns](pattern-match/patterns.md) - [Method todo](method.md) - [Generics and Traits todo](generics-traits/intro.md) diff --git a/src/pattern-match/match-iflet.md b/src/pattern-match/match-iflet.md index 737f8ce..a951610 100644 --- a/src/pattern-match/match-iflet.md +++ b/src/pattern-match/match-iflet.md @@ -65,7 +65,7 @@ fn main() { fn show_message(msg: Message) { match msg { - __ => { // matches Message::Move + __ => { // match Message::Move assert_eq!(a, 1); assert_eq!(b, 3); }, @@ -166,11 +166,11 @@ fn main() { // remove the codes below, using `match` instead if let Foo::Bar = a { - println!("matches foo::bar") + println!("match foo::bar") } else if let Foo::Baz = a { - println!("matches foo::baz") + println!("match foo::baz") } else { - println!("matches others") + println!("match others") } } ``` diff --git a/src/pattern-match/option.md b/src/pattern-match/option.md deleted file mode 100644 index cb5ffa1..0000000 --- a/src/pattern-match/option.md +++ /dev/null @@ -1 +0,0 @@ -# Option destructing diff --git a/src/pattern-match/patterns.md b/src/pattern-match/patterns.md index 3c9daa3..c3f49b9 100644 --- a/src/pattern-match/patterns.md +++ b/src/pattern-match/patterns.md @@ -1 +1,23 @@ # Patterns + +🌟🌟 Using `|` to match several values. +```rust,editable + +fn main() {} +fn match_number(n: i32) { + match n { + // match a single value + 1 => println!("One!"), + // fill in the blank with `|`, DON'T use `..` ofr `..=` + __ => println!("match 2 -> 5"), + // match an inclusive range + 6..=10 => { + println!("match 6 -> 10") + }, + _ => { + println!("match 11 -> +infinite") + } + } +} +``` + diff --git a/zh-CN/src/SUMMARY.md b/zh-CN/src/SUMMARY.md index 6ecda0f..1ca918c 100644 --- a/zh-CN/src/SUMMARY.md +++ b/zh-CN/src/SUMMARY.md @@ -18,9 +18,8 @@ - [结构体](compound-types/struct.md) - [枚举](compound-types/enum.md) - [流程控制](flow-control.md) -- [模式匹配 todo](pattern-match/intro.md) +- [模式匹配](pattern-match/intro.md) - [match, matches! 和 if let](pattern-match/match-iflet.md) - - [解构 Option](pattern-match/option.md) - [模式](pattern-match/patterns.md) - [方法 Method todo](method.md) - [泛型和特征 todo](generics-traits/intro.md) diff --git a/zh-CN/src/pattern-match/match-iflet.md b/zh-CN/src/pattern-match/match-iflet.md index 33d0a29..60208f8 100644 --- a/zh-CN/src/pattern-match/match-iflet.md +++ b/zh-CN/src/pattern-match/match-iflet.md @@ -166,11 +166,11 @@ fn main() { // 移除以下代码,使用 `match` 代替 if let Foo::Bar = a { - println!("matches foo::bar") + println!("match foo::bar") } else if let Foo::Baz = a { - println!("matches foo::baz") + println!("match foo::baz") } else { - println!("matches others") + println!("match others") } } ``` diff --git a/zh-CN/src/pattern-match/option.md b/zh-CN/src/pattern-match/option.md deleted file mode 100644 index cb5ffa1..0000000 --- a/zh-CN/src/pattern-match/option.md +++ /dev/null @@ -1 +0,0 @@ -# Option destructing