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
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
macro_rules! use_prelude {
    () => {
        #[allow(unused_imports)]
        use crate::utils::prelude::*;
    };
}

macro_rules! inlined_modules {(
    $(
        $pub:vis
        mod
        $module_name:ident
        ;
    )*
) => (
    $(
        $pub use self::$module_name::*;
        mod $module_name;
    )*
)}

/// Scoped `use`
macro_rules! using {
    (
        match $expr:tt {
            use :: $($path:tt)::+ ;
            $($match_body:tt)*
        }
    ) => (match $expr { expr => {
        use :: $($path)::+ ;
        match expr { $($match_body)* }
    }});

    (
        match $expr:tt {
            use $($path:tt)::+ ;
            $($match_body:tt)*
        }
    ) => (match $expr { expr => {
        use $($path)::+;
        match expr { $($match_body)* }
    }});

    (
        :: $($path:tt)::+ in $($rest:tt)*
    ) => (
        const _: () = {
            use :: $($path)::+ ;

            $($rest)*
        };
    );
    (
        $($path:tt)::+ in $($rest:tt)*
    ) => (
        const _: () = {
            use $($path)::+ ;

            $($rest)*
        };
    );
}

// macro_rules! FIXME {(
//     $($msg:expr),+ $(; $($body:tt)*)?
// ) => ({
//     #[deprecated(note = "FIXME")] struct __; let _ = __;
//     ::log::warn!("FIXME: {}", ::std::format_args!($($msg),*));
//     $($($body)*)?
// })}

#[allow(clippy::deprecated_cfg_attr)]
#[cfg_attr(rustfmt, rustfmt::skip)]
macro_rules! with_doc {(
    #[doc = $doc:expr]
    $item:item
) => (
    #[doc = $doc]
    $item
)}

macro_rules! trait_alias {(
    $( #[$attr:meta] )*
    $pub:vis
    trait $TraitName:ident = $($super:tt)*
) => (
    with_doc! {
        #[doc = concat!(
            "An alias for `", stringify!($($super)*), "`."
        )]
        $( #[$attr] )*
        $pub
        trait $TraitName
        where
            Self : $($super)*
        {}
    }

    impl<__ : ?Sized> $TraitName for __
    where
        Self : $($super)*
    {}
)}