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

#142 in Procedural macros

Download history 32158/week @ 2024-11-15 32212/week @ 2024-11-22 40206/week @ 2024-11-29 45553/week @ 2024-12-06 34708/week @ 2024-12-13 13797/week @ 2024-12-20 13571/week @ 2024-12-27 37704/week @ 2025-01-03 46260/week @ 2025-01-10 44547/week @ 2025-01-17 46769/week @ 2025-01-24 61004/week @ 2025-01-31 60759/week @ 2025-02-07 46850/week @ 2025-02-14 44432/week @ 2025-02-21 42777/week @ 2025-02-28

205,411 downloads per month
Used in 265 crates (11 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

~200–640KB
~15K SLoC