| Crates.io | cfg-iif |
| lib.rs | cfg-iif |
| version | 0.2.8 |
| created_at | 2021-06-26 01:32:59.701374+00 |
| updated_at | 2025-09-24 07:08:06.400098+00 |
| description | A macro for defining `#[cfg]` `if-else` functions. |
| homepage | |
| repository | https://github.com/aki-akaguma/cfg-iif |
| max_upload_size | |
| id | 415047 |
| size | 54,710 |
A macro for defining #[cfg] if-else functions.
The macro provided by this crate.
Unlike cfg_if,
cfg_iif can be used as a function, and can be used in a function.
#[cfg()]a_iif is "unix" when a os is Unix at compile time:use cfg_iif::cfg_iif;
let a_iif = cfg_iif!(#[cfg(target_family = "unix")] { "unix" } else { "not unix" });
a_iif is "abc" when a feature is "has_abc" at compile time:use cfg_iif::cfg_iif;
let a_iif = cfg_iif!(#[cfg(feature = "has_abc")] { "abc" } else { "not abc" });
a_iif is "abc" when a feature is "has_abc" at compile time:use cfg_iif::cfg_iif;
let mut a_iif = "";
cfg_iif!(
#[cfg(feature = "has_abc")]
{
a_iif = "abc";
}
);
cargo fmta_iif is "abc" when a feature is "has_abc" at compile time:use cfg_iif::cfg_iif;
let a_iif = cfg_iif!(feature = "has_abc" { "abc" } else { "not abc" });
a_iif is "abc" when a feature is "has_abc" at compile time:use cfg_iif::cfg_iif;
let mut a_iif = "";
cfg_iif!(feature = "has_abc" {
a_iif = "abc";
});
This project is licensed under either of
at your option.