Skip to content

Commit

Permalink
Merge pull request #764 from gaochuntie/patch-1
Browse files Browse the repository at this point in the history
Update ch03-05-control-flow.md A small note
  • Loading branch information
KaiserY authored Feb 1, 2024
2 parents 1037626 + fa7fdfa commit 293cdac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ch03-05-control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ again!
`for` 循环的安全性和简洁性使得它成为 Rust 中使用最多的循环结构。即使是在想要循环执行代码特定次数时,例如示例 3-3 中使用 `while` 循环的倒计时例子,大部分 Rustacean 也会使用 `for` 循环。这么做的方式是使用 `Range`,它是标准库提供的类型,用来生成从一个数字开始到另一个数字之前结束的所有数字的序列。

下面是一个使用 `for` 循环来倒计时的例子,它还使用了一个我们还未讲到的方法,`rev`,用来反转 range:
注意: 以下代码不会踏足到数字 9 ,仅从一个数字开始到另一个数字之前

<span class="filename">文件名:src/main.rs</span>

Expand Down

0 comments on commit 293cdac

Please sign in to comment.