本页尚未翻译,以下为英文原文。
#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