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

#169 in Procedural macros

Download history 11752/week @ 2023-12-13 5851/week @ 2023-12-20 4731/week @ 2023-12-27 8304/week @ 2024-01-03 9415/week @ 2024-01-10 13633/week @ 2024-01-17 11525/week @ 2024-01-24 7356/week @ 2024-01-31 7862/week @ 2024-02-07 10010/week @ 2024-02-14 12145/week @ 2024-02-21 9240/week @ 2024-02-28 12361/week @ 2024-03-06 14036/week @ 2024-03-13 13221/week @ 2024-03-20 8878/week @ 2024-03-27

50,466 downloads per month
Used in 7 crates (5 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

~305–750KB
~18K SLoC