1b12ac153Sopenharmony_ci# cfg-if 2b12ac153Sopenharmony_ci 3b12ac153Sopenharmony_ci[Documentation](https://docs.rs/cfg-if) 4b12ac153Sopenharmony_ci 5b12ac153Sopenharmony_ciA macro to ergonomically define an item depending on a large number of #[cfg] 6b12ac153Sopenharmony_ciparameters. Structured like an if-else chain, the first matching branch is the 7b12ac153Sopenharmony_ciitem that gets emitted. 8b12ac153Sopenharmony_ci 9b12ac153Sopenharmony_ci```toml 10b12ac153Sopenharmony_ci[dependencies] 11b12ac153Sopenharmony_cicfg-if = "0.1" 12b12ac153Sopenharmony_ci``` 13b12ac153Sopenharmony_ci 14b12ac153Sopenharmony_ci## Example 15b12ac153Sopenharmony_ci 16b12ac153Sopenharmony_ci```rust 17b12ac153Sopenharmony_cicfg_if::cfg_if! { 18b12ac153Sopenharmony_ci if #[cfg(unix)] { 19b12ac153Sopenharmony_ci fn foo() { /* unix specific functionality */ } 20b12ac153Sopenharmony_ci } else if #[cfg(target_pointer_width = "32")] { 21b12ac153Sopenharmony_ci fn foo() { /* non-unix, 32-bit functionality */ } 22b12ac153Sopenharmony_ci } else { 23b12ac153Sopenharmony_ci fn foo() { /* fallback implementation */ } 24b12ac153Sopenharmony_ci } 25b12ac153Sopenharmony_ci} 26b12ac153Sopenharmony_ci 27b12ac153Sopenharmony_cifn main() { 28b12ac153Sopenharmony_ci foo(); 29b12ac153Sopenharmony_ci} 30b12ac153Sopenharmony_ci``` 31b12ac153Sopenharmony_ci 32b12ac153Sopenharmony_ci# License 33b12ac153Sopenharmony_ci 34b12ac153Sopenharmony_ciThis project is licensed under either of 35b12ac153Sopenharmony_ci 36b12ac153Sopenharmony_ci * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 37b12ac153Sopenharmony_ci http://www.apache.org/licenses/LICENSE-2.0) 38b12ac153Sopenharmony_ci * MIT license ([LICENSE-MIT](LICENSE-MIT) or 39b12ac153Sopenharmony_ci http://opensource.org/licenses/MIT) 40b12ac153Sopenharmony_ci 41b12ac153Sopenharmony_ciat your option. 42b12ac153Sopenharmony_ci 43b12ac153Sopenharmony_ci### Contribution 44b12ac153Sopenharmony_ci 45b12ac153Sopenharmony_ciUnless you explicitly state otherwise, any contribution intentionally submitted 46b12ac153Sopenharmony_cifor inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be 47b12ac153Sopenharmony_cidual licensed as above, without any additional terms or conditions. 48