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

#144 in Procedural macros

Download history 12353/week @ 2024-10-21 29459/week @ 2024-10-28 30986/week @ 2024-11-04 30390/week @ 2024-11-11 30632/week @ 2024-11-18 30464/week @ 2024-11-25 47198/week @ 2024-12-02 43213/week @ 2024-12-09 30753/week @ 2024-12-16 10682/week @ 2024-12-23 18446/week @ 2024-12-30 43186/week @ 2025-01-06 45433/week @ 2025-01-13 45107/week @ 2025-01-20 47479/week @ 2025-01-27 61231/week @ 2025-02-03

201,056 downloads per month
Used in 306 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

~215–660KB
~16K SLoC