5 releases

0.2.0-rc1 Jun 25, 2023
0.1.2 Jun 26, 2023
0.1.1 Jun 25, 2023
0.1.0 Jun 25, 2023
0.0.0 Jun 25, 2023

#195 in Procedural macros

Download history 7895/week @ 2024-08-01 7310/week @ 2024-08-08 10119/week @ 2024-08-15 10448/week @ 2024-08-22 12034/week @ 2024-08-29 12787/week @ 2024-09-05 9392/week @ 2024-09-12 11292/week @ 2024-09-19 13135/week @ 2024-09-26 13488/week @ 2024-10-03 11131/week @ 2024-10-10 13644/week @ 2024-10-17 23163/week @ 2024-10-24 27921/week @ 2024-10-31 27491/week @ 2024-11-07 34735/week @ 2024-11-14

116,024 downloads per month
Used in 188 crates (9 directly)

Zlib OR MIT OR Apache-2.0

16KB
116 lines

::cfg_eval

#[cfg_eval] in stable Rust.

Repository Latest version Documentation MSRV unsafe forbidden License CI

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,
        }
    });
}

Dependencies

~215–650KB
~15K SLoC