pub enum TokenTree {
Group(Group),
Ident(Ident),
Punct(Punct),
Literal(Literal),
}
Expand description
A single token or a delimited sequence of token trees (e.g., [1, (), ..]
).
Variants§
Group(Group)
A token stream surrounded by bracket delimiters.
Ident(Ident)
An identifier.
Punct(Punct)
A single punctuation character (+
, ,
, $
, etc.).
Literal(Literal)
A literal character ('a'
), string ("hello"
), number (2.3
), etc.
Implementations§
Trait Implementations§
1.29.0 · Source§impl Display for TokenTree
Prints the token tree as a string that is supposed to be losslessly convertible back
into the same token tree (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters and negative numeric literals.
impl Display for TokenTree
Prints the token tree as a string that is supposed to be losslessly convertible back
into the same token tree (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters and negative numeric literals.
Note: the exact form of the output is subject to change, e.g. there might
be changes in the whitespace used between tokens. Therefore, you should
not do any kind of simple substring matching on the output string (as
produced by to_string
) to implement a proc macro, because that matching
might stop working if such changes happen. Instead, you should work at the
TokenTree
level, e.g. matching against TokenTree::Ident
,
TokenTree::Punct
, or TokenTree::Literal
.
1.30.0 · Source§impl Extend<TokenTree> for TokenStream
impl Extend<TokenTree> for TokenStream
Source§fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, trees: I)
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, trees: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
#72631)1.29.0 · Source§impl From<TokenTree> for TokenStream
Creates a token stream containing a single token tree.
impl From<TokenTree> for TokenStream
Creates a token stream containing a single token tree.
Source§fn from(tree: TokenTree) -> TokenStream
fn from(tree: TokenTree) -> TokenStream
1.29.0 · Source§impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
Source§impl ToTokens for TokenTree
impl ToTokens for TokenTree
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
proc_macro_totokens
#130977)Source§fn into_token_stream(self) -> TokenStream
fn into_token_stream(self) -> TokenStream
proc_macro_totokens
#130977)Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
proc_macro_totokens
#130977)