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

#155 in Procedural macros

Download history 31299/week @ 2024-12-14 11199/week @ 2024-12-21 17479/week @ 2024-12-28 42675/week @ 2025-01-04 44355/week @ 2025-01-11 44826/week @ 2025-01-18 47774/week @ 2025-01-25 62189/week @ 2025-02-01 60491/week @ 2025-02-08 42833/week @ 2025-02-15 45571/week @ 2025-02-22 52538/week @ 2025-03-01 58419/week @ 2025-03-08 57189/week @ 2025-03-15 64273/week @ 2025-03-22 48150/week @ 2025-03-29

237,102 downloads per month
Used in 352 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

~195–630KB
~15K SLoC