docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#E0083: invalid enum value

A value enum (V = n) has only value variants, each with a distinct constant that fits the tag type. Fix the variants the message names.

nabi
enum Code { Ok = 0, Bad = 0 }
error[E0083]: `Code::Bad` and `Code::Ok` have the same value 0
  --> main.nabi:1:1
   |
 1 | enum Code { Ok = 0, Bad = 0 }
   | ^^^^

Give each variant its own value:

nabi
enum Code { Ok = 0, Bad = 1 }
println(f"{Code::Bad as i32}");
1

Related: E0094 invalid representation

Found a mistake? Edit this page on GitHub. Last updated