Skip to content

Commit ba66c01

Browse files
committed
cpubits: vendor the full cfg_if! macro
If we do this, we can potentially drop `cfg-if` as a dependency from crates that use `cpubits`, which would cut down on the impression of the total number of dependencies those crates have.
1 parent 27e5257 commit ba66c01

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

cpubits/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,32 @@ macro_rules! cpubits {
230230
};
231231
}
232232

233-
/// Vendored partial copy of the `cfg_if::cfg_if` macro.
233+
/// Vendored copy of the `cfg_if::cfg_if` macro.
234234
/// Copyright (c) 2014 Alex Crichton. Dual-licensed Apache 2.0 + MIT.
235235
#[doc(hidden)]
236236
#[macro_export]
237237
macro_rules! cfg_if {
238+
(
239+
if #[cfg( $($i_meta:tt)+ )] { $( $i_tokens:tt )* }
240+
$(
241+
else if #[cfg( $($ei_meta:tt)+ )] { $( $ei_tokens:tt )* }
242+
)*
243+
$(
244+
else { $( $e_tokens:tt )* }
245+
)?
246+
) => {
247+
$crate::cfg_if! {
248+
@__items () ;
249+
(( $($i_meta)+ ) ( $( $i_tokens )* )),
250+
$(
251+
(( $($ei_meta)+ ) ( $( $ei_tokens )* )),
252+
)*
253+
$(
254+
(() ( $( $e_tokens )* )),
255+
)?
256+
}
257+
};
258+
238259
// Internal and recursive macro to emit all the items
239260
//
240261
// Collects all the previous cfgs in a list at the beginning, so they can be

0 commit comments

Comments
 (0)