Files
comlexr/macro/src/macros.rs
2025-01-30 21:04:54 -05:00

14 lines
381 B
Rust

macro_rules! enum_to_tokens {
($enum:ident: $($variant:ident),*) => {
impl ToTokens for $enum {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
tokens.extend(match self {
$(Self::$variant(variant) => quote! { #variant },)*
});
}
}
};
}
pub(crate) use enum_to_tokens;