[−][src]Enum syntex_syntax2::tokenstream::TokenTree
When the main rust parser encounters a syntax-extension invocation, it parses the arguments to the invocation as a token-tree. This is a very loose structure, such that all sorts of different AST-fragments can be passed to syntax extensions using a uniform type.
If the syntax extension is an MBE macro, it will attempt to match its
LHS token tree against the provided token tree, and if it finds a
match, will transcribe the RHS token tree, splicing in any captured
macro_parser::matched_nonterminals
into the SubstNt
s it finds.
The RHS of an MBE macro is the only place SubstNt
s are substituted.
Nothing special happens to misnamed or misplaced SubstNt
s.
Variants
Token(Span, Token)
A single token
Delimited(Span, Delimited)
A delimited sequence of token trees
Methods
impl TokenTree
[src]
pub fn parse(
cx: &ExtCtxt,
mtch: &[TokenTree],
tts: TokenStream
) -> NamedParseResult
[src]
cx: &ExtCtxt,
mtch: &[TokenTree],
tts: TokenStream
) -> NamedParseResult
Use this token tree as a matcher to parse given tts.
pub fn eq_unspanned(&self, other: &TokenTree) -> bool
[src]
Check if this TokenTree is equal to the other, regardless of span information.
pub fn span(&self) -> Span
[src]
Retrieve the TokenTree's span.
pub fn eq_token(&self, t: Token) -> bool
[src]
Indicates if the stream is a token that is equal to the provided token.
Trait Implementations
impl ToTokens for TokenTree
[src]
impl PartialEq<TokenTree> for TokenTree
[src]
impl Clone for TokenTree
[src]
fn clone(&self) -> TokenTree
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<TokenTree> for TokenStream
[src]
fn from(tt: TokenTree) -> TokenStream
[src]
impl Eq for TokenTree
[src]
impl Hash for TokenTree
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for TokenTree
[src]
impl<'de> Deserialize<'de> for TokenTree
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for TokenTree
[src]
Auto Trait Implementations
impl !Sync for TokenTree
impl !Send for TokenTree
impl Unpin for TokenTree
impl !RefUnwindSafe for TokenTree
impl !UnwindSafe for TokenTree
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,