Why this fires¶
An @flags enum is generic, or has a variant that carries a payload. @flags enums represent a bitmask over a fixed, flat set of unit variants — there's no room for type parameters or per-variant payloads in that model.
@flags
enum Perm: u8 {
Read,
Write(int),
// ^^^ error[TE119]: @flags enum `Perm` requires all-unit variants;
// `Write` has a payload
}Fix it¶
Drop the payload (and any type parameters):
@flags
enum Perm: u8 { Read, Write, Exec } // ok — all unit variantsSee also¶
TE120— a flag value isn't a power of two or a known composite.TE121— a flag value doesn't fit the backing type.TE122— two flags occupy the same bit.- /docs/data-structures#enums —
@flagsbit-flag enums.