Skip to content

Commit 9b1f5ee

Browse files
committed
Updated src/programming_concepts/functions.md'.
1 parent c82fc42 commit 9b1f5ee

File tree

7 files changed

+124
-117
lines changed

7 files changed

+124
-117
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,5 @@ Rust 语言希望也能支持许多其他用户;这里提到的只是一些最
132132

133133
## 本书的源码
134134

135-
本书所产生的源码,可在 [Github: gnu4cn/rust-lang](https://github.com/gnu4cn/rust-lang-zh_CN/projects) 下载到。
135+
本书所产生的源码,可在 [Github: gnu4cn/rust-lang](https://github.com/gnu4cn/rust-lang-zh_CN/tree/main/projects) 下载到。
136136

projects/expressions/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "expressions"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

projects/expressions/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let y = {
3+
let x = 3;
4+
x + 1;
5+
};
6+
7+
println! ("y 的值为:{:?}", y);
8+
}

projects/functions/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[package]
22
name = "functions"
33
version = "0.1.0"
4-
edition = "2021"
5-
6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
4+
edition = "2024"
75

86
[dependencies]

src/Ch00_Forword_and_Introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ Rust 语言希望也能支持许多其他用户;这里提到的只是一些最
126126

127127
阅读本书并无定法:你要跳着去读,也是可以的!在遇到疑惑时,或许就不得不跳回去看看了。你只要怎么有效就行了。
128128

129-
学习 Rust 过程中的一个重要部分是学习如何阅读编译器给出的错误信息:这些信息将指导咱们编写工作的代码。因此,我们将提供许多不能编译的例子,以及编译器在每种情况下显示的错误信息。要知道,如果咱们随便输入并运行一个例子,他可能不会被编译!请确保咱们阅读报错周围的文字,看看咱们试图运行的例子是否会出错。
129+
学习 Rust 过程中的一个重要部分是学习如何阅读编译器给出的错误信息:这些信息将指导咱们编写出工作的代码。因此,我们将提供许多不能编译的例子,以及编译器在每种情况下显示的错误信息。要知道,如果咱们随便输入并运行一个例子,他可能不会被编译!请确保咱们阅读报错周围的文字,看看咱们试图运行的例子是否会出错。
130130

131131
在大多数情况下,我们会带着找到任何不能编译的代码的正确版本。
132132

133133
## 本书的源码
134134

135-
本书所产生的源码,可在 [Github: gnu4cn/rust-lang](https://github.com/gnu4cn/rust-lang-zh_CN/projects) 下载到。
135+
本书所产生的源码,可在 [Github: gnu4cn/rust-lang](https://github.com/gnu4cn/rust-lang-zh_CN/tree/main/projects) 下载到。
136136

137137

138138
(End)

src/Ch02_Programming_a_Guessing_Game.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() {
100100
}
101101
```
102102

103-
<a name="#list-2-1"></a>
103+
<a name="#listing_2-1"></a>
104104
*清单 2-1,从用户处获取一个猜数并将其打印出来的代码*
105105

106106
这段代码包含了大量信息,所以我们来逐行查看。要获取用户输入,然后将结果作为输出打印,我们就需要将 `io` 这个输入/输出库,带入作用域。`io` 库来自标准库,称为 `std`
@@ -360,7 +360,7 @@ remote: Total 1043606 (delta 693593), reused 848030 (delta 620187), pack-reused
360360
Finished `dev` profile [unoptimized + debuginfo] target(s) in 9m 51s
361361
```
362362

363-
<a name="#list-2-2"></a>
363+
<a name="#listing_2-2"></a>
364364
*清单 2-2:在添加 `rand` 代码箱作为依赖项添加后,运行 `cargo build` 的输出**
365365

366366
> **译注**:这里译者使用了国内的 `ustc` Cargo 登记簿镜像。
@@ -455,7 +455,7 @@ fn main() {
455455
}
456456
```
457457

458-
<a name="#list-2-3"></a>
458+
<a name="#listing_2-3"></a>
459459
*清单 2-3:添加生成随机数的代码*
460460

461461

@@ -521,7 +521,7 @@ fn main() {
521521
}
522522
}
523523
```
524-
<a name="#list-2-4"></a>
524+
<a name="#listing_2-4"></a>
525525
*清单 2-4:处理比较两个数字可能的返回值*
526526

527527

@@ -756,7 +756,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
756756
// --跳过--
757757
```
758758

759-
<a name="list-2-5"></a>
759+
<a name="listing_2-5"></a>
760760
*清单 2-5:忽略非数字的猜数并请求另一猜数,而不是让崩溃程序*
761761

762762

@@ -829,7 +829,7 @@ fn main() {
829829
}
830830
```
831831

832-
<a name="#list-2-6"></a>
832+
<a name="#listing_2-6"></a>
833833
*清单 2-6:完整的猜数游戏代码*
834834

835835

0 commit comments

Comments
 (0)