Unnamed repository; edit this file 'description' to name the repository.
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
//! Types representing the three basic "styles" of macro calls in Rust source:
//! - Function-like macros ("bang macros"), e.g. `foo!(...)`
//! - Attribute macros, e.g. `#[foo]`
//! - Derive macros, e.g. `#[derive(Foo)]`

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MacroCallStyle {
    FnLike,
    Attr,
    Derive,
}

bitflags::bitflags! {
    /// A set of `MacroCallStyle` values, allowing macros to indicate that
    /// they support more than one style.
    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
    pub struct MacroCallStyles: u8 {
        const FN_LIKE = (1 << 0);
        const ATTR = (1 << 1);
        const DERIVE = (1 << 2);
    }
}

impl From<MacroCallStyle> for MacroCallStyles {
    fn from(kind: MacroCallStyle) -> Self {
        match kind {
            MacroCallStyle::FnLike => Self::FN_LIKE,
            MacroCallStyle::Attr => Self::ATTR,
            MacroCallStyle::Derive => Self::DERIVE,
        }
    }
}