commit | 22079200fec60c6460a8b53a2e7332ff5e1ca1d4 | [log] [tgz] |
---|---|---|
author | Matt Lee <matthewhlee@google.com> | Tue Dec 06 21:36:09 2022 -0800 |
committer | Matt Lee <matthewhlee@google.com> | Tue Dec 06 21:36:09 2022 -0800 |
tree | 922148d864e3db4510c9ac0118a0c1a4a95056de | |
parent | 5b90b971b24a6af173a29e90c82a098579fff522 [diff] | |
parent | 8499f0874c123a905c185bc07017777b9a743406 [diff] |
Merge t-qpr-2022-12 Change-Id: I89a9d4fe8f2b00cc61671df94698fb8fe62f0599
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.