Pular para o conteúdo
TE122 · Tipos · error

Duas flags ocupam o mesmo bit

Duas flags de bit único no mesmo enum `@flags` resolveram para o mesmo bit, normalmente porque receberam o mesmo valor explícito.

Why this fires

Two single-bit flags in the same @flags enum resolved to the same bit — usually because both were given the same explicit value.

@flags
enum Perm: u8 {
    Read  = 1,
    Write = 1,
    //      ^ error[TE122]: flags `Perm::Read` and `Perm::Write` occupy the same bit 1
}

Fix it

Give each single-bit flag a distinct power of two, or drop the explicit values and let them auto-increment:

@flags
enum Perm: u8 {
    Read,                     // 1
    Write,                    // 2
}

See also

Veja também

Buscar no Zolo

9 resultados

en