#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 上编辑此页 最后更新: