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

#168 in Procedural macros

Download history 106034/week @ 2025-12-12 66625/week @ 2025-12-19 33119/week @ 2025-12-26 92094/week @ 2026-01-02 124334/week @ 2026-01-09 117836/week @ 2026-01-16 108677/week @ 2026-01-23 117995/week @ 2026-01-30 117534/week @ 2026-02-06 108092/week @ 2026-02-13 112555/week @ 2026-02-20 118249/week @ 2026-02-27 160538/week @ 2026-03-06 140010/week @ 2026-03-13 161489/week @ 2026-03-20 142936/week @ 2026-03-27

629,926 downloads per month
Used in 590 crates (22 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

~110–480KB
~11K SLoC