macroex/
transparent_tokens.rs

1//! implements no changes versions of [`ToTokens`]
2use quote::ToTokens;
3
4use crate::*;
5
6macro_rules! raw {
7    ($($name: ident),* $(,)?) => {
8        $(impl quote::ToTokens for $name{
9            fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
10                self.0.to_tokens(tokens)
11            }
12        })*
13    };
14}
15
16macro_rules! no_bounds {
17    ($($name: ident),* $(,)?) => {
18        $(impl<T> quote::ToTokens for $name<T> where T: ToTokens{
19            fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
20                self.0.to_tokens(tokens)
21            }
22        })*
23    };
24}
25
26raw!(
27    IdentString, ParenthesizedGroup, BracketedGroup, CurlyBracedGroup,
28);
29
30no_bounds!(
31    Number, NumberList, Splat, ArrayRepeat, TupleList,
32    Parenthesized, Bracketed, CurlyBraced,
33    NotParenthesized, NotBracketed, NotCurlyBraced,
34);
35
36
37impl<T, const N: usize> quote::ToTokens for Repeat<T, N> where T: ToTokens {
38    fn to_tokens(&self, tokens: &mut TokenStream) {
39        self.0.to_tokens(tokens)
40    }
41}