aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
blob: 5c9ffb80d9148bfac06d04c5ebec25469bb42335 (plain)
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
macro_rules! trait_alias {
    (
        $(#[$attr: meta])*
        $visibility: vis $name: ident$(<$($type_param: ident),*>)?$(: $first_bound: tt $(+ $bound: tt)*)?;
    ) => {
        $(#[$attr])*
        $visibility trait $name $(<$($type_param),*>)? $(: $first_bound $(+ $bound)*)? {}

        impl<T: $($first_bound $(+ $bound)*)?, $($($type_param),*)?> $name$(<$($type_param),*>)? for T {}
    };
}

macro_rules! feature_alternate {
    (
        feature = $feature: literal,
        $(#[doc = $doc: literal])*
        when_enabled = $when_enabled: item,
        when_disabled = $when_disabled: item
    ) => {
        $(#[doc = $doc])*
        #[cfg(feature = $feature)]
        $when_enabled

        $(#[doc = $doc])*
        #[cfg(not(feature = $feature))]
        $when_disabled
    };
}

pub(crate) use {feature_alternate, trait_alias};