commit | b8af5d6fc65fce49b6aa5f93e7d0ec3f0ab90f3d | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Thu Oct 08 17:21:27 2020 -0700 |
committer | Xin Li <delphij@google.com> | Thu Oct 08 17:21:27 2020 -0700 |
tree | 9f53b461009a2611d3ee163fd22cd03401f946fa | |
parent | f5549b90452b007bd66f7f83e255ac8e9253e3f6 [diff] | |
parent | c946b00980d545e139cf88e036e45487a6dd162b [diff] |
Skip ab/6749736 in stage. Merged-In: I85955ea022870392a28a1e14613b84f589cd5094 Change-Id: I0144c0a6f15562c35ede8c1c6bd8dc5cc21e1c7f
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.