Skip to content

[Bug]: Implicit value not starting at 1 #46

@hamidrezakp

Description

@hamidrezakp

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Current Behaviour

sets variant values starting at 0

Expected Behaviour

set variants starting at 1

Environment Information

rust: rustc 1.89.0
linux: Linux pc 6.16.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 15 Aug 2025 16:04:43 +0000 x86_64 GNU/Linux
flagset: 0.4.7 with no features

Steps To Reproduce

This code fails when expecting the variant A to be 1.

use flagset::flags;

fn main() {
    let f = Flag::A;
    assert_eq!(f as u64, 1); // This fails.
}

flags! {
    enum Flag: u64 {
        A, // should be 0b001 but is 0b000
        B  // should be 0b002 but is 0b001 
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions