Skip to content

Commit 58684cd

Browse files
author
WaySLOG
committed
Merge pull request #146 from jqs7/master
fix some typo
2 parents f133f56 + cacb1d6 commit 58684cd

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

06-flow/06-02-condition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let z = if let Some(y) = x {
7676
}
7777
else {
7878
0
79-
}
79+
};
8080
// z 值为 5
8181

8282
```
@@ -93,7 +93,7 @@ match x {
9393
let z = match x {
9494
Some(y) => y,
9595
None => 0
96-
}
96+
};
9797
```
9898

9999
设计这个语法的目的是,在条件判断的时候,直接做一次模式匹配,方便代码书写,使代码更紧凑。

07-type/07-02-compound-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```rust
88
let y = (2, "hello world");
9-
let x: (3, &str) = (3, "world hello");
9+
let x: (i32, &str) = (3, "world hello");
1010

1111
// 然后呢,你能用很简单的方式去访问他们:
1212

08-function/08-02-return_value.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
```rust
2121
fn main() {
2222
let a = 3;
23-
println!("{}", inc(3));
23+
println!("{}", inc(a));
2424
}
2525

26-
fn inc(n: i32) -> i32 {
26+
fn inc(n: i32) -> i32 {
2727
n + 1
2828
}
2929
```

09-match/09-02-pattern.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 模式
22
模式,是Rust另一个强大的语法。它可以被用在`let``match`表达式里面。相信大家应该还记得我们在[基础类型](../07-type/07-01-types.md)中提到的关于在let表达式中解构元组的例子,实际上这就是一个模式。
33
```rust
4-
let tup = (0u9,1u8);
4+
let tup = (0u8,1u8);
55
let (x, y) = tup;
66
```
77
而且我们需要知道的是,一个模式中如果出现了和前面的同名变量,则这个变量会在当前作用域里被模式中的值覆盖掉。比如:
@@ -73,7 +73,7 @@ match point {
7373

7474
## 忽略和内存管理
7575

76-
总结以下,我们遇到了两种不同的模式忽略的情况——`_``..`。这里要注意,模式匹配中被忽略的字段是不会被`move`的,而且实现`Copy`的也会优先被Copy而不是被`move`
76+
总结一下,我们遇到了两种不同的模式忽略的情况——`_``..`。这里要注意,模式匹配中被忽略的字段是不会被`move`的,而且实现`Copy`的也会优先被Copy而不是被`move`
7777

7878
说的有点拗口,上代码:
7979

@@ -87,7 +87,7 @@ let (x, s) = tuple;
8787

8888
let tuple = (5, String::from("five"));
8989

90-
/// 忽略String类型,而u32实现了Copy,则tuple不会被move
90+
// 忽略String类型,而u32实现了Copy,则tuple不会被move
9191
let (x, _) = tuple;
9292

9393
println!("Tuple is: {:?}", tuple);
@@ -113,8 +113,8 @@ let c = 'w';
113113

114114
match c {
115115
'a' ... 'z' => println!("小写字母"),
116-
'A' ... 'Z' => pringln!("大写字母"),
117-
_ => pringln!("其他字符"),
116+
'A' ... 'Z' => println!("大写字母"),
117+
_ => println!("其他字符"),
118118
}
119119
```
120120

12-ownership-system/12-01-ownership.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct Bar { //不可实现Copy特性
201201
1. **通过derive让Rust编译器自动实现**
202202

203203
```rust
204-
#derive(Copy, Clone)]
204+
#[derive(Copy, Clone)]
205205
struct Foo {
206206
a: i32,
207207
b: bool,

0 commit comments

Comments
 (0)