Why this fires¶
A flag's value is out of range for the enum's backing type. enum: u8 bit-flags top out at 255 (bit 7); a larger explicit value has no room in that backing type.
@flags
enum Perm: u8 {
Big = 256,
// ^^^ error[TE121]: flag value 256 for `Perm::Big` does not fit backing type `u8` (max 255)
}Fix it¶
Widen the backing type, or use a value that fits:
@flags
enum Perm: u16 {
Big = 256, // ok — u16 covers up to 65535
}See also¶
TE120— a flag value isn't a power of two or a known composite.TE122— two flags occupy the same bit.- /docs/data-structures#enums —
@flagsbit-flag enums and backing types.