aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / cfg-if / README.md
| 1 | # cfg-if |
| 2 | |
| 3 | > [!WARNING] |
| 4 | > This crate has been "replaced" by the [`cfg_select!`] macro, which is stable since Rust 1.95.0 with a slightly different syntax. Barring breakages and security fixes, this crate will no longer be updated. |
| 5 | |
| 6 | [`cfg_select!`]: https://doc.rust-lang.org/std/macro.cfg_select.html |
| 7 | |
| 8 | [Documentation](https://docs.rs/cfg-if) |
| 9 | |
| 10 | A macro to ergonomically define an item depending on a large number of #[cfg] |
| 11 | parameters. Structured like an if-else chain, the first matching branch is the |
| 12 | item that gets emitted. |
| 13 | |
| 14 | ```toml |
| 15 | [dependencies] |
| 16 | cfg-if = "1.0" |
| 17 | ``` |
| 18 | |
| 19 | ## Example |
| 20 | |
| 21 | ```rust |
| 22 | cfg_if::cfg_if! { |
| 23 | if #[cfg(unix)] { |
| 24 | fn foo() { /* unix specific functionality */ } |
| 25 | } else if #[cfg(target_pointer_width = "32")] { |
| 26 | fn foo() { /* non-unix, 32-bit functionality */ } |
| 27 | } else { |
| 28 | fn foo() { /* fallback implementation */ } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | fn main() { |
| 33 | foo(); |
| 34 | } |
| 35 | ``` |
| 36 | The `cfg_if!` block above is expanded to: |
| 37 | ```rust |
| 38 | #[cfg(unix)] |
| 39 | fn foo() { /* unix specific functionality */ } |
| 40 | #[cfg(all(target_pointer_width = "32", not(unix)))] |
| 41 | fn foo() { /* non-unix, 32-bit functionality */ } |
| 42 | #[cfg(not(any(unix, target_pointer_width = "32")))] |
| 43 | fn foo() { /* fallback implementation */ } |
| 44 | ``` |
| 45 | |
| 46 | # License |
| 47 | |
| 48 | This project is licensed under either of |
| 49 | |
| 50 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or |
| 51 | https://www.apache.org/licenses/LICENSE-2.0) |
| 52 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or |
| 53 | https://opensource.org/licenses/MIT) |
| 54 | |
| 55 | at your option. |
| 56 | |
| 57 | ### Contribution |
| 58 | |
| 59 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 60 | for inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be |
| 61 | dual licensed as above, without any additional terms or conditions. |