commit | 3ab505921e7dae98fed1527c90dad93b5210d738 | [log] [tgz] |
---|---|---|
author | Stephen Crane <cranes@google.com> | Wed Jul 07 19:09:37 2021 -0700 |
committer | Stephen Crane <cranes@google.com> | Wed Jul 07 19:09:37 2021 -0700 |
tree | 64fd2f6a3c8aae72991c398bbb95e5cab98fb95c | |
parent | 756b6045ee5e3227836d97d1c4b12974d62ec1f1 [diff] |
Make std dependency injection conditional Makes the std injection for building as a dylib actually conditional on building a dylib. This allows other crate types (i.e. rlib) to be usable in a no_std environment. Test: m libcfg_if Bug: 193087363 Change-Id: I0f144731dd8a22b30f9b400ff223d040ec229c35
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.