Skip to main content

TokenTreeWithMetadata

Enum TokenTreeWithMetadata 

Source
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:

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>

Source

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.

Source

pub fn span(&self) -> Span

Gets the span of this token.

See TokenTree::span.

Source

pub fn set_span(&mut self, span: Span)

Sets the span of this token.

See TokenTree::set_span.

Source§

impl<T> TokenTreeWithMetadata<T>

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> TokenTreeWithMetadata<G, I, P, L>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug, I: Debug, P: Debug, L: Debug> Debug for TokenTreeWithMetadata<G, I, P, L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<G, I, P, L> From<(Group, &G, &I, &P, &L)> for TokenTreeWithMetadata<G, I, P, L>
where G: Clone, I: Clone, P: Clone, L: Clone,

Source§

fn from(group_and_vals: (Group, &G, &I, &P, &L)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(Group, &T)> for TokenTreeWithMetadata<T>
where T: Clone,

Source§

fn from(group_and_val: (Group, &T)) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<(Ident, I)> for TokenTreeWithMetadata<G, I, P, L>

Source§

fn from((ident, metadata): (Ident, I)) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<(Literal, L)> for TokenTreeWithMetadata<G, I, P, L>

Source§

fn from((literal, metadata): (Literal, L)) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<(Punct, P)> for TokenTreeWithMetadata<G, I, P, L>

Source§

fn from((punct, metadata): (Punct, P)) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<(TokenTree, &G, &I, &P, &L)> for TokenTreeWithMetadata<G, I, P, L>
where G: Clone, I: Clone, P: Clone, L: Clone,

Source§

fn from((tree, g, i, p, l): (TokenTree, &G, &I, &P, &L)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(TokenTree, &T)> for TokenTreeWithMetadata<T>
where T: Clone,

Source§

fn from((tree, metadata): (TokenTree, &T)) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<Group> for TokenTreeWithMetadata<G, I, P, L>
where G: Default, I: Default, P: Default, L: Default,

Source§

fn from(group: Group) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<Ident> for TokenTreeWithMetadata<G, I, P, L>
where I: Default,

Source§

fn from(ident: Ident) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<Literal> for TokenTreeWithMetadata<G, I, P, L>
where L: Default,

Source§

fn from(literal: Literal) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<Punct> for TokenTreeWithMetadata<G, I, P, L>
where P: Default,

Source§

fn from(punct: Punct) -> Self

Converts to this type from the input type.
Source§

impl<G, I, P, L> From<TokenTree> for TokenTreeWithMetadata<G, I, P, L>
where G: Default, I: Default, P: Default, L: Default,

Source§

fn from(tree: TokenTree) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<G, I = G, P = G, L = I> !Send for TokenTreeWithMetadata<G, I, P, L>

§

impl<G, I = G, P = G, L = I> !Sync for TokenTreeWithMetadata<G, I, P, L>

§

impl<G, I, P, L> Freeze for TokenTreeWithMetadata<G, I, P, L>
where G: Freeze, I: Freeze, P: Freeze, L: Freeze,

§

impl<G, I, P, L> RefUnwindSafe for TokenTreeWithMetadata<G, I, P, L>

§

impl<G, I, P, L> Unpin for TokenTreeWithMetadata<G, I, P, L>
where G: Unpin, I: Unpin, P: Unpin, L: Unpin,

§

impl<G, I, P, L> UnsafeUnpin for TokenTreeWithMetadata<G, I, P, L>

§

impl<G, I, P, L> UnwindSafe for TokenTreeWithMetadata<G, I, P, L>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.