cfg_eval.rs

`#[cfg_eval]` in stable Rust

APACHE-2.0 License

Downloads
615.6K
Stars
5

::cfg_eval

#[cfg_eval] in stable Rust.

Example

use ::macro_rules_attribute::apply;

#[macro_use]
extern crate cfg_eval;

fn main()
{
    let output_without_cfg_eval = {
        #[apply(stringify!)]
        enum Foo {
            Bar,

            #[cfg(FALSE)]
            NonExisting,
        }
    };
    // This is usually not great.
    assert!(output_without_cfg_eval.contains("NonExisting"));

    let output_with_cfg_eval = {
        #[cfg_eval]
        #[apply(stringify!)]
        enum Foo {
            Bar,

            #[cfg(FALSE)]
            NonExisting,
        }
    };
    assert_eq!(output_with_cfg_eval, stringify! {
        enum Foo {
            Bar,
        }
    });
}
Package Rankings
Top 22.54% on Crates.io
Badges
Extracted from project README
Repository Latest version Documentation MSRV unsafe forbidden License CI