本頁尚未翻譯,以下為英文原文。
#E0104: invalid rest pattern
A pattern has at most one .., and a rest pattern goes only where the message says. Remove the extra ...
nabi
enum E { A(i32, i32, i32) }
let v = E::A(1, 2, 3);
match v {
E::A(x, .., y, ..) => println(f"{x}"),
}
error[E0104]: pattern `E::A` has more than one `..` --> main.nabi:4:1 | 4 | match v { | ^^^^^^^^^
Keep one ..:
nabi
enum E { A(i32, i32, i32) }
let v = E::A(1, 2, 3);
match v {
E::A(x, .., y) => println(f"{x} {y}"),
}
1 3
Related: E0101 wrong number of fields in a pattern
Found a mistake? Edit this page on GitHub. Last updated