# Crate cfg_if [−] [src]

A macro for defining #[cfg] if-else statements.

The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, emitting the implementation which matches first.

This allows you to conveniently provide a long list #[cfg]'d blocks of code without having to rewrite each clause multiple times.

# Example

    #[macro_use]
    extern crate 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 */ }
        }
    }

## Macros

cfg_if |

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)