水木社区手机版
首页
|版面-Rust编程语言(Rust)|
新版wap站已上线
返回
1/1
|
转到
主题:[求助]为什么这里分号有没有都行
楼主
|
woshidashu
|
2025-08-30 09:39:50
|
只看此ID
let mut counter = 0;
let result = loop {
counter += 1;
if counter == 10 {
break counter * 2; //为啥这里的分号有没有都行
}
};
println!("The result is {}", result);
--
FROM 124.129.22.*
1楼
|
RunningOn
|
2025-09-04 14:17:16
|
只看此ID
你就理解为语法包容吧,反正不会生产歧义,就类似于 fn foo(a: i32,) 这里有没有逗号都一样。
【 在 woshidashu 的大作中提到: 】
: let mut counter = 0;
: let result = loop {
: counter += 1;
: ...................
--
FROM 116.237.207.*
1/1
|
转到
选择讨论区
首页
|
分区
|
热推
BYR-Team
©
2010.
KBS Dev-Team
©
2011
登录完整版