Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for const variants #2

Open
henninglive opened this issue Feb 25, 2017 · 4 comments
Open

Support for const variants #2

henninglive opened this issue Feb 25, 2017 · 4 comments
Assignees

Comments

@henninglive
Copy link
Contributor

henninglive commented Feb 25, 2017

Is possible to implement support for const variants?

@MaikKlein
Copy link
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,
}

@henninglive
Copy link
Contributor Author

Yes

@MaikKlein MaikKlein self-assigned this Feb 27, 2017
@MaikKlein
Copy link
Owner

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

@MaikKlein
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants