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

Analog to std::cfg! macro #7

Closed
CreepySkeleton opened this issue Nov 6, 2019 · 1 comment · Fixed by #30
Closed

Analog to std::cfg! macro #7

CreepySkeleton opened this issue Nov 6, 2019 · 1 comment · Fixed by #30

Comments

@CreepySkeleton
Copy link

Sometimes it's neat to have a macro expanding to true orfalse instead of attribute. I propose to implement rusversion::cfg!(stable...) macro.

By the way, I believe it can be implemented via

macro_rules! cfg {
    ($(tts:tt)*) => {{
        #[rustversion::$(tts)*] fn do_cfg() { true }
        #[rustversion::not($(tts)*)] fn do_cfg() { false }

        do_cfg()
    }}
}
@jhpratt
Copy link

jhpratt commented Nov 27, 2020

@dtolnay Function-like and attribute macros can exist in the same crate with the same name, correct? If so, I think this should be relatively easy to modify the existing code to add support for this. I may be able to do it if my understanding is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants