cfg_eval

Crates.iocfg_eval
lib.rscfg_eval
version0.1.2
sourcesrc
created_at2023-06-25 16:19:49.938884
updated_at2023-06-26 09:58:05.413501
description`#[cfg_eval]` in stable Rust 🙃
homepage
repositoryhttps://github.com/danielhenrymantilla/cfg_eval.rs
max_upload_size
id899618
size40,088
Daniel Henry-Mantilla (danielhenrymantilla)

documentation

https://docs.rs/cfg_eval

README

::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,
        }
    });
}
Commit count: 9

cargo fmt