Registry / utility / cfg-if

cfg-if

JSON →
library1.0.4rscratesunverified

A macro to ergonomically define an item depending on a large number of #[cfg] parameters, structured like an if-else chain.

# Cargo.toml [dependencies] cfg-if = "1.0.4"
INSTALL
IMPORT
SIG · CFG-IF
C
cfg-if
utilityrustv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cfg_if
✓ use cfg_if::cfg_if;

Shows how to use cfg_if! to conditionally compile code based on platform.

use cfg_if::cfg_if; cfg_if! { if #[cfg(unix)] { fn platform() -> &'static str { "unix" } } else if #[cfg(windows)] { fn platform() -> &'static str { "windows" } } else { fn platform() -> &'static str { "unknown" } } } fn main() { println!("{}", platform()); }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.0.4latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
cfg-if — cargo add cfg-if · libregistry