Skip to content

Support for const variants #2

Description

@henninglive

Is possible to implement support for const variants?

Activity

  1. MaikKlein commented on Feb 27, 2017

    @MaikKlein
    Owner

    Could you explain what you mean by const?

    Something like this?

    const FOO: u8 = 0b0100;
     #[derive(EnumFlags, Copy, Clone, Debug)]
    #[repr(u8)]
    pub enum Test {
        A = 0b0001,
        B = 0b0010,
        C = FOO,
        D = 0b1000,
    }
    
  2. henninglive commented on Feb 27, 2017

    @henninglive
    ContributorAuthor

    Yes

  3. self-assigned this
    on Feb 27, 2017
  4. MaikKlein commented on Feb 27, 2017

    @MaikKlein
    Owner

    This should be possible, unless syn doesn't expose this in ConstExpr.

  5. MaikKlein commented on Feb 28, 2017

    @MaikKlein
    Owner

    I am not quite sure if that is currently possible. I don't see a way to access the value of a const var. https://dtolnay.github.io/syn/syn/struct.PathSegment.html

    Alternatively I could implement another derive that wouldn't do any safety checks, then I don't need to inspect the value and therefore const values could be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions