#E0014: 修飾詞順序錯誤
函式修飾詞有固定的順序 unsafe async yield fn,每個最多出現一次,而 throws 要放在回傳型別之前:fn f() throws -> T。請依照 help 提示調整順序。
nabi
fn parse(s: str) -> i32 throws {
0
}
error[E0014]: `throws` goes before the return type --> main.nabi:1:25 | 1 | fn parse(s: str) -> i32 throws { | ^^^^^^ | = help: write `fn parse(s: str) throws -> i32`
把 throws 放在回傳型別之前:
nabi
fn parse(s: str) throws -> i32 {
try s.parse::<i32>()
}
println(f"{try! parse("7")}");
7
相關錯誤碼:E0023 無效的函式簽章
發現錯誤? 在 GitHub 上編輯此頁 最後更新: