Enum syntax::ext::tt::quoted::TokenTree [−][src]
pub enum TokenTree { Token(Span, Token), Delimited(Span, Lrc<Delimited>), Sequence(Span, Lrc<SequenceRepetition>), MetaVar(Span, Ident), MetaVarDecl(Span, Ident, Ident), }
Similar to tokenstream::TokenTree
, except that $i
, $i:ident
, and $(...)
are "first-class" token trees. Useful for parsing macros.
Variants
Token(Span, Token)
Delimited(Span, Lrc<Delimited>)
Sequence(Span, Lrc<SequenceRepetition>)
A kleene-style repetition sequence
MetaVar(Span, Ident)
E.g. $var
MetaVarDecl(Span, Ident, Ident)
E.g. $var:expr
. This is only used in the left hand side of MBE macros.
Methods
impl TokenTree
[src]
impl TokenTree
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Return the number of tokens in the tree.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the given token tree contains no other tokens. This is vacuously true for single tokens or metavar/decls, but may be false for delimited trees or sequences.
pub fn get_tt(&self, index: usize) -> TokenTree
[src]
pub fn get_tt(&self, index: usize) -> TokenTree
Get the index
-th sub-token-tree. This only makes sense for delimited trees and sequences.
pub fn span(&self) -> Span
[src]
pub fn span(&self) -> Span
Retrieve the TokenTree
's span.
Trait Implementations
impl Debug for TokenTree
[src]
impl Debug for TokenTree
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for TokenTree
[src]
impl Clone for TokenTree
fn clone(&self) -> TokenTree
[src]
fn clone(&self) -> TokenTree
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for TokenTree
[src]
impl PartialEq for TokenTree
fn eq(&self, other: &TokenTree) -> bool
[src]
fn eq(&self, other: &TokenTree) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &TokenTree) -> bool
[src]
fn ne(&self, other: &TokenTree) -> bool
This method tests for !=
.
impl Eq for TokenTree
[src]
impl Eq for TokenTree
impl Encodable for TokenTree
[src]
impl Encodable for TokenTree
impl Decodable for TokenTree
[src]
impl Decodable for TokenTree
impl Hash for TokenTree
[src]
impl Hash for TokenTree