本頁尚未翻譯,以下為英文原文。
#E0013: struct literal in a block head
In the head of if, while, match or for, a { opens the body, so a struct literal there is read wrongly. Wrap the literal in parentheses: if p == (Point { x: 0, y: 0 }) { .. }.
nabi
struct P { x: i32; }
match P { x: 2 } {
P { x } => println(f"{x}"),
}
error[E0013]: a struct literal can't start a block's head: its `{` would open the body --> main.nabi:3:7 | 3 | match P { x: 2 } { | ^^^^^^^^^^ | = help: wrap the struct literal in parentheses: `(P { x: 2 })`
Wrap the literal in parentheses:
nabi
struct P { x: i32; }
match (P { x: 2 }) {
P { x } => println(f"{x}"),
}
2
Related: E0010 unexpected token
Found a mistake? Edit this page on GitHub. Last updated