docs

你正在阅读 v0.1.0 的文档。Nabi 0.1.0 已不再提供支持。 最新版本:v0.1.3 →

本页尚未翻译,以下为英文原文。

#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