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

Feature/Rust: Use #[cfg()] in enum/foreign_enum #376

Open
kwek20 opened this issue Feb 19, 2021 · 0 comments
Open

Feature/Rust: Use #[cfg()] in enum/foreign_enum #376

kwek20 opened this issue Feb 19, 2021 · 0 comments

Comments

@kwek20
Copy link

kwek20 commented Feb 19, 2021

Hi!

I would like to have a specific enum generated only when the rust config has a feature enabled as well.

Rust enum example:

pub enum ManagerStorage {
    /// Specialstorage.
    #[cfg(any(feature = "feature1", feature = "feature2"))]
    SPECIAL,
    /// Cool storage.
    #[cfg(feature = "feature3")]
    COOL,
    /// Regular storage.
    REGULAR
}

If I try to add these cfg options inside a foreign_enum macro, I receive the following error:
error: Expect doc attribute or doc comment or derive here, got 'cfg (any (feature = "feature1" , feature = "feature2"))'

If I leave out the cfg options, and compile without those features i get the following error: (Java example)
no variant or associated item named "COOL" found for enum "ManagerStorage" in the current scope
(Due to the actual enum beeing linked to something in the feature crate)

Is there a way to do this currently?

Thank you for developing this crate!

@kwek20 kwek20 changed the title Rust: Use #[cfg()] in enum/foreign_enum Feature/Rust: Use #[cfg()] in enum/foreign_enum Feb 19, 2021
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