commit | 7aea746d3d3b0303f3ec3c73c84e8f729f3034f1 | [log] [tgz] |
---|---|---|
author | Scott Lobdell <slobdell@google.com> | Fri Jan 21 07:03:31 2022 +0000 |
committer | Scott Lobdell <slobdell@google.com> | Fri Jan 21 07:15:03 2022 +0000 |
tree | abc738c06c30a249bc5052a166faa4ab7ea12dc6 | |
parent | b452363befcc3c7a355bcffac16d6426385e541e [diff] | |
parent | ea20704618dd74218d31f6e17d20a0f9c300474e [diff] |
Merge TP1A.211206.001 Change-Id: I50836fb4f7ca4f1a77e573e247fc8067111d4871
A macro to ergonomically define an item depending on a large number of #[cfg] parameters. Structured like an if-else chain, the first matching branch is the item that gets emitted.
[dependencies] cfg-if = "0.1"
cfg_if::cfg_if! { if #[cfg(unix)] { fn foo() { /* unix specific functionality */ } } else if #[cfg(target_pointer_width = "32")] { fn foo() { /* non-unix, 32-bit functionality */ } } else { fn foo() { /* fallback implementation */ } } } fn main() { foo(); }
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in cfg-if
by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.