add expressions-zh.md

This commit is contained in:
sunface 2022-02-25 14:34:31 +08:00
parent 574097924b
commit 357fa1bc24
1 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
# Statements and Expressions
# 语句与表达式
### Examples
### 示例
```rust,editable
fn main() {
let x = 5u32;
@ -9,12 +9,12 @@ fn main() {
let x_squared = x * x;
let x_cube = x_squared * x;
// This expression will be assigned to `y`
// 下面表达式的值将被赋给 `y`
x_cube + x_squared + x
};
let z = {
// The semicolon suppresses this expression and `()` is assigned to `z`
// 分号让表达式变成了语句,因此返回的不再是表达式 `2 * x` 的值,而是语句的值 `()`
2 * x;
};
@ -24,10 +24,10 @@ fn main() {
}
```
### exercises
### 练习
🌟🌟
```rust,editable
// make it work with two ways: both modify the inner {}
// 使用两种方法修改内部的 {} 中的内容
fn main() {
let v = {
let mut x = 1;