cfg-iif
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.
Features
- minimum support rustc 1.56.1 (59eed8a2a 2021-11-01)
Example
Example 1: #[cfg()]
a_iif
is "unix" when a os is Unix at compile time:
use cfg_iif;
let a_iif = cfg_iif!;
a_iif
is "abc" when a feature is "has_abc" at compile time:
use cfg_iif;
let a_iif = cfg_iif!;
a_iif
is "abc" when a feature is "has_abc" at compile time:
use cfg_iif;
let mut a_iif = "";
cfg_iif!;
Example 2: a short hand for a firendly cargo fmt
a_iif
is "abc" when a feature is "has_abc" at compile time:
use cfg_iif;
let a_iif = cfg_iif!;
a_iif
is "abc" when a feature is "has_abc" at compile time:
use cfg_iif;
let mut a_iif = "";
cfg_iif!;
Changelogs
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.