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