10
由於分號顯然是可選的拉斯特,爲什麼,如果我這樣做:分號在Rust中是否可選?
fn fn1() -> i32 {
let a = 1
let b = 2
3
}
我得到的錯誤:
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> src/main.rs:3:9
|
2 | let a = 1
| - expected one of `.`, `;`, `?`, or an operator here
3 | let b = 2
| ^^^ unexpected token
?
您也可以查看https://rustbyexample.com/expression.html關於也提到分號的表達式。 – nbro 2018-02-11 21:52:14