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§
impl !Send for TokenTree
impl !Sync for TokenTree
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::Groups
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::Groups
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)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one #72631)Source§#[doc(hidden)]unsafe fn extend_one_unchecked(&mut self, item: A)where
Self: Sized,
#[doc(hidden)]unsafe fn extend_one_unchecked(&mut self, item: A)where
Self: Sized,
extend_one_unchecked)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)Auto Trait Implementations§
impl Freeze for TokenTree
impl RefUnwindSafe for TokenTree
impl Unpin for TokenTree
impl UnsafeUnpin for TokenTree
impl UnwindSafe for TokenTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> RepToTokensExt for T
impl<T> RepToTokensExt for T
Source§fn next(&self) -> Option<&Self>
fn next(&self) -> Option<&Self>
proc_macro_internals)quote_into_iter.
This allows repeated calls to quote_into_iter to continue
correctly returning DoesNotHaveIter.Source§fn quote_into_iter(&self) -> (&Self, DoesNotHaveIter)
fn quote_into_iter(&self) -> (&Self, DoesNotHaveIter)
proc_macro_internals)Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type #102070)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more