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

#166 in Procedural macros

Download history 10218/week @ 2024-01-12 13505/week @ 2024-01-19 11384/week @ 2024-01-26 5277/week @ 2024-02-02 9993/week @ 2024-02-09 11246/week @ 2024-02-16 10479/week @ 2024-02-23 10927/week @ 2024-03-01 13319/week @ 2024-03-08 12632/week @ 2024-03-15 12520/week @ 2024-03-22 10017/week @ 2024-03-29 13044/week @ 2024-04-05 13451/week @ 2024-04-12 13961/week @ 2024-04-19 13065/week @ 2024-04-26

56,651 downloads per month
Used in 10 crates (7 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

~315–770KB
~18K SLoC