pub enum TokenTreeWithMetadata<G, I = G, P = G, L = I> {
Group(GroupWithMetadata<G, I, P, L>),
Ident(TokenWithMetadata<Ident, I>),
Punct(TokenWithMetadata<Punct, P>),
Literal(TokenWithMetadata<Literal, L>),
}Expand description
A version of TokenTree with arbitrary attached metadata.
Each variant holds metadata of a different type. The types are:
G: ForGroupWithMetadatas (inproc_macro2,Groups).I: ForIdenttokens (defaults to the same type asG).P: ForPuncttokens (defaults to the same type asG).L: ForLiteraltokens (defaults to the same type asI).
See proc_macro2’s documentation for more information.
Variants§
Group(GroupWithMetadata<G, I, P, L>)
A GroupWithMetadata token with its corresponding metadata.
The tokens within the group, correspondingly, also have metadata, with
the same types.
Ident(TokenWithMetadata<Ident, I>)
An Ident token with its corresponding metadata.
Punct(TokenWithMetadata<Punct, P>)
A Punct token with its corresponding metadata.
Literal(TokenWithMetadata<Literal, L>)
A Literal token with its corresponding metadata.
Implementations§
Source§impl<G, I, P, L> TokenTreeWithMetadata<G, I, P, L>
impl<G, I, P, L> TokenTreeWithMetadata<G, I, P, L>
Sourcepub fn strip_metadata(self) -> TokenTree
pub fn strip_metadata(self) -> TokenTree
Strips the metadata from this TokenTreeWithMetadata, returning an
ordinary TokenTree. Child GroupWithMetadatas will also be
stripped of their metadata.
Sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
Gets the span of this token.
See TokenTree::span.
Sourcepub fn set_span(&mut self, span: Span)
pub fn set_span(&mut self, span: Span)
Sets the span of this token.
See TokenTree::set_span.
Source§impl<T> TokenTreeWithMetadata<T>
impl<T> TokenTreeWithMetadata<T>
Sourcepub fn get_metadata(self) -> T
pub fn get_metadata(self) -> T
Consumes self and returns the metadata associated with this token. Only available when all metadata types are the same.
Sourcepub fn get_metadata_ref(&self) -> &T
pub fn get_metadata_ref(&self) -> &T
Returns a reference to the metadata associated with this token. Only available when all metadata types are the same.
Sourcepub fn get_metadata_mut(&mut self) -> &mut T
pub fn get_metadata_mut(&mut self) -> &mut T
Returns a mutable reference to the metadata associated with this token. Only available when all metadata types are the same.
Sourcepub fn set_metadata(&mut self, metadata: T)
pub fn set_metadata(&mut self, metadata: T)
Sets the metadata associated with this token. Only available when all metadata types are the same.
Trait Implementations§
Source§impl<G: Clone, I: Clone, P: Clone, L: Clone> Clone for TokenTreeWithMetadata<G, I, P, L>
impl<G: Clone, I: Clone, P: Clone, L: Clone> Clone for TokenTreeWithMetadata<G, I, P, L>
Source§fn clone(&self) -> TokenTreeWithMetadata<G, I, P, L>
fn clone(&self) -> TokenTreeWithMetadata<G, I, P, L>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more