本页尚未翻译,以下为英文原文。
#E0014: modifiers out of order
Function modifiers go in one order, unsafe async yield fn, each at most once, and throws goes before the return type: fn f() throws -> T. Reorder them as the help shows.
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`
Put throws before the return type:
nabi
fn parse(s: str) throws -> i32 {
try s.parse::<i32>()
}
println(f"{try! parse("7")}");
7
Related: E0023 invalid function signature
Found a mistake? Edit this page on GitHub. Last updated