mbe/
macro_call_style.rs

1//! Types representing the three basic "styles" of macro calls in Rust source:
2//! - Function-like macros ("bang macros"), e.g. `foo!(...)`
3//! - Attribute macros, e.g. `#[foo]`
4//! - Derive macros, e.g. `#[derive(Foo)]`
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum MacroCallStyle {
8    FnLike,
9    Attr,
10    Derive,
11}
12
13bitflags::bitflags! {
14    /// A set of `MacroCallStyle` values, allowing macros to indicate that
15    /// they support more than one style.
16    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
17    pub struct MacroCallStyles: u8 {
18        const FN_LIKE = (1 << 0);
19        const ATTR = (1 << 1);
20        const DERIVE = (1 << 2);
21    }
22}
23
24impl From<MacroCallStyle> for MacroCallStyles {
25    fn from(kind: MacroCallStyle) -> Self {
26        match kind {
27            MacroCallStyle::FnLike => Self::FN_LIKE,
28            MacroCallStyle::Attr => Self::ATTR,
29            MacroCallStyle::Derive => Self::DERIVE,
30        }
31    }
32}