Enum rustc_expand::mbe::TokenTree
source · [−]enum TokenTree {
Token(Token),
Delimited(DelimSpan, Lrc<Delimited>),
Sequence(DelimSpan, Lrc<SequenceRepetition>),
MetaVar(Span, Ident),
MetaVarDecl(Span, Ident, Option<NonterminalKind>),
}Expand description
Similar to tokenstream::TokenTree, except that $i, $i:ident, and $(...)
are “first-class” token trees. Useful for parsing macros.
Variants
Token(Token)
Delimited(DelimSpan, Lrc<Delimited>)
Sequence(DelimSpan, Lrc<SequenceRepetition>)
A kleene-style repetition sequence
MetaVar(Span, Ident)
e.g., $var
MetaVarDecl(Span, Ident, Option<NonterminalKind>)
e.g., $var:expr. This is only used in the left hand side of MBE macros.
Implementations
sourceimpl TokenTree
impl TokenTree
sourcefn is_delimited(&self) -> bool
fn is_delimited(&self) -> bool
Returns true if the given token tree is delimited.
sourcefn is_token(&self, expected_kind: &TokenKind) -> bool
fn is_token(&self, expected_kind: &TokenKind) -> bool
Returns true if the given token tree is a token of the given kind.
sourcefn get_tt(&self, index: usize) -> TokenTree
fn get_tt(&self, index: usize) -> TokenTree
Gets the index-th sub-token-tree. This only makes sense for delimited trees and sequences.
fn token(kind: TokenKind, span: Span) -> TokenTree
Trait Implementations
impl StructuralPartialEq for TokenTree
Auto Trait Implementations
impl !RefUnwindSafe for TokenTree
impl !Send for TokenTree
impl !Sync for TokenTree
impl Unpin for TokenTree
impl !UnwindSafe for TokenTree
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes
Size for each variant:
Token: 31 bytesDelimited: 31 bytesSequence: 31 bytesMetaVar: 23 bytesMetaVarDecl: 23 bytes