Skip to content
TE121 · Type · error

Flag value does not fit the backing type

A flag's value is out of range for the enum's backing type — `enum: u8` bit-flags top out at `255` (bit 7).

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

See also

Search Zolo

9 results

en