Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/macro_call_style.rs')
| -rw-r--r-- | crates/mbe/src/macro_call_style.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/mbe/src/macro_call_style.rs b/crates/mbe/src/macro_call_style.rs new file mode 100644 index 0000000000..311f0cb98d --- /dev/null +++ b/crates/mbe/src/macro_call_style.rs @@ -0,0 +1,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, + } + } +} |