Enum TokenTree

pub enum TokenTree

A single token or a delimited sequence of token trees (e.g. [1, (), ..]).

Variants

Group(Group)

A token stream surrounded by bracket delimiters.

Ident(Ident)

An identifier.

Punct(Punct)

A single punctuation character (+, ,, $, etc.).

Literal(Literal)

A literal character ('a'), string ("hello"), number (2.3), etc.

Implementations

impl TokenTree

fn span(&self) -> Span

Returns the span of this tree, delegating to the span method of the contained token or a delimited stream.

fn set_span(&mut self, span: Span)

Configures the span for only this token.

Note that if this token is a Group then this method will not configure the span of each of the internal tokens, this will simply delegate to the set_span method of each variant.

Trait Implementations

impl Clone for TokenTree

fn clone(&self) -> TokenTree

impl Debug for TokenTree

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

impl Display for TokenTree

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

impl From<Group> for TokenTree

fn from(g: Group) -> Self

impl From<Ident> for TokenTree

fn from(g: Ident) -> Self

impl From<Literal> for TokenTree

fn from(g: Literal) -> Self

impl From<Punct> for TokenTree

fn from(g: Punct) -> Self

Auto Trait Implementations

impl !Send for TokenTree

impl !Sync for TokenTree

impl Freeze for TokenTree

impl RefUnwindSafe for TokenTree

impl Unpin for TokenTree

impl UnsafeUnpin for TokenTree

impl UnwindSafe for TokenTree

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for TokenTree

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for TokenTree where T: Display + ?Sized,

fn to_string(&self) -> String

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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