14 lines
381 B
Rust
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;
|