Skip to content

Commit e44454f

Browse files
authored
Update variables2.rs
1 parent 3adaa34 commit e44454f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

exercises/variables/variables2.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// variables2.rs
2-
//
3-
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
4-
// hint.
5-
6-
71
fn main() {
2+
// 1. 声明不可变变量x,绑定值10(Rust自动推导类型为i32)
83
let x = 10;
4+
5+
// 2. 条件判断:检查x是否等于10(Rust的if条件无需括号,且必须是布尔值)
96
if x == 10 {
7+
// 条件成立时执行(本例中必然走这里)
108
println!("x is ten!");
119
} else {
10+
// 条件不成立时执行(本例不会触发)
1211
println!("x is not ten!");
1312
}
1413
}

0 commit comments

Comments
 (0)