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 TokenTreepub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturn the number of tokens in the tree.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolReturns 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) -> TokenTreeGet 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) -> SpanRetrieve the TokenTree's span.
Trait Implementations
impl Debug for TokenTree[src]
impl Debug for TokenTreefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Clone for TokenTree[src]
impl Clone for TokenTreefn clone(&self) -> TokenTree[src]
fn clone(&self) -> TokenTreeReturns 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 TokenTreefn eq(&self, other: &TokenTree) -> bool[src]
fn eq(&self, other: &TokenTree) -> boolThis 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) -> boolThis method tests for !=.
impl Eq for TokenTree[src]
impl Eq for TokenTreeimpl Encodable for TokenTree[src]
impl Encodable for TokenTreeimpl Decodable for TokenTree[src]
impl Decodable for TokenTreeimpl Hash for TokenTree[src]
impl Hash for TokenTree