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

#165 in Procedural macros

Download history 14036/week @ 2024-03-13 13214/week @ 2024-03-20 8886/week @ 2024-03-27 13345/week @ 2024-04-03 12558/week @ 2024-04-10 15441/week @ 2024-04-17 14699/week @ 2024-04-24 13521/week @ 2024-05-01 12250/week @ 2024-05-08 16724/week @ 2024-05-15 16390/week @ 2024-05-22 18210/week @ 2024-05-29 14666/week @ 2024-06-05 14406/week @ 2024-06-12 15085/week @ 2024-06-19 17228/week @ 2024-06-26

64,195 downloads per month
Used in 10 crates (8 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

~280–730KB
~17K SLoC