1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 /// A macro for defining `#[cfg]` if-else statements.
13 /// This is similar to the `if/elif` C preprocessor macro by allowing definition
14 /// of a cascade of `#[cfg]` cases, emitting the implementation which matches
17 /// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
18 /// without having to rewrite each clause multiple times.
21 if #[cfg($($meta:meta),*)] { $($it:item)* }
27 $( ( ($($meta),*) ($($it)*) ), )*
33 macro_rules! __cfg_if_items {
34 (($($not:meta,)*) ; ) => {};
35 (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => {
36 __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* }
37 __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* }
41 macro_rules! __cfg_if_apply {
42 ($m:meta, $($it:item)*) => {