interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / cfg-if / README.md

61 lines · 1727 bytes Raw Blame History Rendered
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
10A macro to ergonomically define an item depending on a large number of #[cfg]
11parameters. Structured like an if-else chain, the first matching branch is the
12item that gets emitted.
13
14```toml
15[dependencies]
16cfg-if = "1.0"
17```
18
19## Example
20
21```rust
22cfg_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
32fn main() {
33 foo();
34}
35```
36The `cfg_if!` block above is expanded to:
37```rust
38#[cfg(unix)]
39fn foo() { /* unix specific functionality */ }
40#[cfg(all(target_pointer_width = "32", not(unix)))]
41fn foo() { /* non-unix, 32-bit functionality */ }
42#[cfg(not(any(unix, target_pointer_width = "32")))]
43fn foo() { /* fallback implementation */ }
44```
45
46# License
47
48This 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
55at your option.
56
57### Contribution
58
59Unless you explicitly state otherwise, any contribution intentionally submitted
60for inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be
61dual licensed as above, without any additional terms or conditions.