pub enum TokenTree {
Group(Group),
Ident(Ident),
Punct(Punct),
Literal(Literal),
}Expand description
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§
Trait Implementations§
Source§impl Display for TokenTree
Prints the token tree as a string that is supposed to be losslessly
convertible back into the same token tree (modulo spans), except for
possibly TokenTree::Groups with Delimiter::None delimiters and negative
numeric literals.
impl Display for TokenTree
Prints the token tree as a string that is supposed to be losslessly
convertible back into the same token tree (modulo spans), except for
possibly TokenTree::Groups with Delimiter::None delimiters and negative
numeric literals.
Source§impl Extend<TokenTree> for TokenStream
impl Extend<TokenTree> for TokenStream
Source§fn extend<I>(&mut self, streams: I)where
I: IntoIterator<Item = TokenTree>,
fn extend<I>(&mut self, streams: I)where
I: IntoIterator<Item = TokenTree>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl From<BraceGroup> for TokenTree
impl From<BraceGroup> for TokenTree
Source§fn from(group: BraceGroup) -> TokenTree
fn from(group: BraceGroup) -> TokenTree
Converts to this type from the input type.
Source§impl<C> From<BraceGroupContaining<C>> for TokenTreewhere
C: ToTokens,
impl<C> From<BraceGroupContaining<C>> for TokenTreewhere
C: ToTokens,
Source§fn from(group: BraceGroupContaining<C>) -> TokenTree
fn from(group: BraceGroupContaining<C>) -> TokenTree
Converts to this type from the input type.
Source§impl From<BracketGroup> for TokenTree
impl From<BracketGroup> for TokenTree
Source§fn from(group: BracketGroup) -> TokenTree
fn from(group: BracketGroup) -> TokenTree
Converts to this type from the input type.
Source§impl<C> From<BracketGroupContaining<C>> for TokenTreewhere
C: ToTokens,
impl<C> From<BracketGroupContaining<C>> for TokenTreewhere
C: ToTokens,
Source§fn from(group: BracketGroupContaining<C>) -> TokenTree
fn from(group: BracketGroupContaining<C>) -> TokenTree
Converts to this type from the input type.
Source§impl<T> From<Cached<T>> for TokenTree
Convert a Cached<T: Into<TokenTree>> object into a TokenTree.
impl<T> From<Cached<T>> for TokenTree
Convert a Cached<T: Into<TokenTree>> object into a TokenTree.
Source§impl<C> From<GroupContaining<C>> for TokenTreewhere
C: ToTokens,
impl<C> From<GroupContaining<C>> for TokenTreewhere
C: ToTokens,
Source§fn from(group: GroupContaining<C>) -> TokenTree
fn from(group: GroupContaining<C>) -> TokenTree
Converts to this type from the input type.
Source§impl From<LiteralCharacter> for TokenTree
impl From<LiteralCharacter> for TokenTree
Source§fn from(lit: LiteralCharacter) -> TokenTree
fn from(lit: LiteralCharacter) -> TokenTree
Converts to this type from the input type.
Source§impl From<LiteralInteger> for TokenTree
impl From<LiteralInteger> for TokenTree
Source§fn from(lit: LiteralInteger) -> TokenTree
fn from(lit: LiteralInteger) -> TokenTree
Converts to this type from the input type.
Source§impl From<LiteralString> for TokenTree
impl From<LiteralString> for TokenTree
Source§fn from(lit: LiteralString) -> TokenTree
fn from(lit: LiteralString) -> TokenTree
Converts to this type from the input type.
Source§impl<C> From<NoneGroupContaining<C>> for TokenTreewhere
C: ToTokens,
impl<C> From<NoneGroupContaining<C>> for TokenTreewhere
C: ToTokens,
Source§fn from(group: NoneGroupContaining<C>) -> TokenTree
fn from(group: NoneGroupContaining<C>) -> TokenTree
Converts to this type from the input type.
Source§impl From<ParenthesisGroup> for TokenTree
impl From<ParenthesisGroup> for TokenTree
Source§fn from(group: ParenthesisGroup) -> TokenTree
fn from(group: ParenthesisGroup) -> TokenTree
Converts to this type from the input type.
Source§impl<C> From<ParenthesisGroupContaining<C>> for TokenTreewhere
C: ToTokens,
impl<C> From<ParenthesisGroupContaining<C>> for TokenTreewhere
C: ToTokens,
Source§fn from(group: ParenthesisGroupContaining<C>) -> TokenTree
fn from(group: ParenthesisGroupContaining<C>) -> TokenTree
Converts to this type from the input type.
Source§impl<const C: char> From<PunctAlone<C>> for TokenTree
Convert a PunctAlone object into a TokenTree.
impl<const C: char> From<PunctAlone<C>> for TokenTree
Convert a PunctAlone object into a TokenTree.
Source§fn from(_: PunctAlone<C>) -> TokenTree
fn from(_: PunctAlone<C>) -> TokenTree
Converts to this type from the input type.
Source§impl<const C: char> From<PunctAny<C>> for TokenTree
Convert a PunctAny object into a TokenTree.
impl<const C: char> From<PunctAny<C>> for TokenTree
Convert a PunctAny object into a TokenTree.
Source§impl<const C: char> From<PunctJoint<C>> for TokenTree
Convert a PunctJoint object into a TokenTree.
impl<const C: char> From<PunctJoint<C>> for TokenTree
Convert a PunctJoint object into a TokenTree.
Source§fn from(_: PunctJoint<C>) -> TokenTree
fn from(_: PunctJoint<C>) -> TokenTree
Converts to this type from the input type.
Source§impl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
Source§fn from(token: TokenTree) -> TokenStream
fn from(token: TokenTree) -> TokenStream
Converts to this type from the input type.
Source§impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
Source§fn from_iter<I>(streams: I) -> TokenStreamwhere
I: IntoIterator<Item = TokenTree>,
fn from_iter<I>(streams: I) -> TokenStreamwhere
I: IntoIterator<Item = TokenTree>,
Creates a value from an iterator. Read more
Source§impl Parser for TokenTree
impl Parser for TokenTree
Source§fn parser(tokens: &mut TokenIter) -> Result<TokenTree, Error>
fn parser(tokens: &mut TokenIter) -> Result<TokenTree, Error>
The actual parsing function that must be implemented. This mutates the
tokens
iterator directly. It should not be called from user code except for implementing
parsers itself and then only when the rules below are followed. Read moreSource§impl ToTokens for TokenTree
impl ToTokens for TokenTree
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
Convert
self into a TokenIter object.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Convert
&self into a TokenStream object.Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Convert
self into a TokenStream object.Auto Trait Implementations§
impl Freeze for TokenTree
impl RefUnwindSafe for TokenTree
impl !Send for TokenTree
impl !Sync for TokenTree
impl Unpin for TokenTree
impl UnwindSafe for TokenTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynamicTokens for T
impl<T> DynamicTokens for T
Source§impl<T> Parse for Twhere
T: Parser,
impl<T> Parse for Twhere
T: Parser,
Source§fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
This is the user facing API to parse grammatical entities. Calls a
parser() within a
transaction. Commits changes on success and returns the parsed value. Read more