1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/// Provides the ability to define `#[cfg]` statements for multiple items /// /// ### Examples /// ```ignore /// use fungus::prelude::*; /// /// cfgblk! { /// #[cfg(feature = "foo")]) /// use libc; /// use std::ffi::CString; /// } /// /// // Expands to /// #[cfg(feature = "foo")]) /// use libc; /// #[cfg(feature = "foo")]) /// use std::ffi::CString; /// ``` #[macro_export] macro_rules! cfgblock { // Handle a single item (#[$attr:meta] $item:item) => { #[$attr] $item }; // Handle more than one item recursively (#[$attr:meta] $($tail:item)*) => { $(cfgblock!{#[$attr] $tail})* }; }