Crates.io | cfg_eval |
lib.rs | cfg_eval |
version | 0.1.2 |
source | src |
created_at | 2023-06-25 16:19:49.938884 |
updated_at | 2023-06-26 09:58:05.413501 |
description | `#[cfg_eval]` in stable Rust 🙃 |
homepage | |
repository | https://github.com/danielhenrymantilla/cfg_eval.rs |
max_upload_size | |
id | 899618 |
size | 40,088 |
::cfg_eval
#[cfg_eval]
in stable Rust.
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,
}
});
}