[go: up one dir, main page]

match_cfg 0.1.0

A convenience macro to ergonomically define an item depending on a large number of `#[cfg]` parameters. Structured like match statement, the first matching branch is the item that gets emitted.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 19.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 545.19 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • gnzlbg/match_cfg
    9 0 2
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gnzlbg

match_cfg

Build Status

Documentation

Minimum Supported Rust Version: 1.13.0.

A convenience macro to ergonomically define an item depending on a large number of #[cfg] parameters. Structured like match statement, the first matching branch is the item that gets emitted.

[dependencies]
match_cfg = "0.1"

The use_core feature is enabled by default and builds the crate with libcore as a dependency by using the #![no_std] attribute. When this feature is disabled, this crate is built without libcore support by using the #![no_core] attribute - this makes use of the #![feature(no_core)] and requires a nightly version of Rust.

Example

#[macro_use(match_cfg)]
extern crate match_cfg;

match_cfg! {
    #[cfg(unix)] => {
         fn foo() { /* unix specific functionality */ }
     }
     #[cfg(target_pointer_width = "32")] => {
         fn foo() { /* non-unix, 32-bit functionality */ }
     }
     _ => {
         fn foo() { /* fallback implementation */ }
     }
}

fn main() {
    foo();
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.