Enum syntax::parse::token::Token [−][src]
pub enum Token { Eq, Lt, Le, EqEq, Ne, Ge, Gt, AndAnd, OrOr, Not, Tilde, BinOp(BinOpToken), BinOpEq(BinOpToken), At, Dot, DotDot, DotDotDot, DotDotEq, DotEq, Comma, Semi, Colon, ModSep, RArrow, LArrow, FatArrow, Pound, Dollar, Question, SingleQuote, OpenDelim(DelimToken), CloseDelim(DelimToken), Literal(Lit, Option<Name>), Ident(Ident, bool), Lifetime(Ident), Interpolated(Lrc<(Nonterminal, LazyTokenStream)>), DocComment(Name), Whitespace, Comment, Shebang(Name), Eof, }
Variants
Eq
Lt
Le
EqEq
Ne
Ge
Gt
AndAnd
OrOr
Not
Tilde
BinOp(BinOpToken)
BinOpEq(BinOpToken)
At
Dot
DotDot
DotDotDot
DotDotEq
DotEq
Comma
Semi
Colon
ModSep
RArrow
LArrow
FatArrow
Pound
Dollar
Question
SingleQuote
Used by proc macros for representing lifetimes, not generated by lexer right now.
OpenDelim(DelimToken)
An opening delimiter, eg. {
CloseDelim(DelimToken)
A closing delimiter, eg. }
Literal(Lit, Option<Name>)
Ident(Ident, bool)
Lifetime(Ident)
Interpolated(Lrc<(Nonterminal, LazyTokenStream)>)
DocComment(Name)
Doc comment
Whitespace
Whitespace
Comment
Comment
Shebang(Name)
Eof
Methods
impl Token
[src]
impl Token
pub fn interpolated(nt: Nonterminal) -> Token
[src]
pub fn interpolated(nt: Nonterminal) -> Token
pub fn from_ast_ident(ident: Ident) -> Token
[src]
pub fn from_ast_ident(ident: Ident) -> Token
Recovers a Token
from an ast::Ident
. This creates a raw identifier if necessary.
pub fn is_like_gt(&self) -> bool
[src]
pub fn is_like_gt(&self) -> bool
Returns true
if the token starts with '>'.
pub fn can_begin_expr(&self) -> bool
[src]
pub fn can_begin_expr(&self) -> bool
Returns true
if the token can appear at the start of an expression.
pub fn can_begin_type(&self) -> bool
[src]
pub fn can_begin_type(&self) -> bool
Returns true
if the token can appear at the start of a type.
pub fn can_begin_bound(&self) -> bool
[src]
pub fn can_begin_bound(&self) -> bool
Returns true
if the token can appear at the start of a generic bound.
pub fn is_lit(&self) -> bool
[src]
pub fn is_lit(&self) -> bool
Returns true
if the token is any literal
pub fn can_begin_literal_or_bool(&self) -> bool
[src]
pub fn can_begin_literal_or_bool(&self) -> bool
Returns true
if the token is any literal, a minus (which can follow a literal,
for example a '-42', or one of the boolean idents).
pub fn ident(&self) -> Option<(Ident, bool)>
[src]
pub fn ident(&self) -> Option<(Ident, bool)>
Returns an identifier if this token is an identifier.
pub fn lifetime(&self) -> Option<Ident>
[src]
pub fn lifetime(&self) -> Option<Ident>
Returns a lifetime identifier if this token is a lifetime.
pub fn is_ident(&self) -> bool
[src]
pub fn is_ident(&self) -> bool
Returns true
if the token is an identifier.
pub fn is_lifetime(&self) -> bool
[src]
pub fn is_lifetime(&self) -> bool
Returns true
if the token is a lifetime.
pub fn is_ident_named(&self, name: &str) -> bool
[src]
pub fn is_ident_named(&self, name: &str) -> bool
Returns true
if the token is a identifier whose name is the given
string slice.
pub fn is_doc_comment(&self) -> bool
[src]
pub fn is_doc_comment(&self) -> bool
Returns true
if the token is a documentation comment.
pub fn is_interpolated(&self) -> bool
[src]
pub fn is_interpolated(&self) -> bool
Returns true
if the token is interpolated.
pub fn is_path(&self) -> bool
[src]
pub fn is_path(&self) -> bool
Returns true
if the token is an interpolated path.
pub fn is_mutability(&self) -> bool
[src]
pub fn is_mutability(&self) -> bool
Returns true
if the token is either the mut
or const
keyword.
pub fn is_qpath_start(&self) -> bool
[src]
pub fn is_qpath_start(&self) -> bool
pub fn is_path_start(&self) -> bool
[src]
pub fn is_path_start(&self) -> bool
pub fn is_keyword(&self, kw: Keyword) -> bool
[src]
pub fn is_keyword(&self, kw: Keyword) -> bool
Returns true
if the token is a given keyword, kw
.
pub fn is_path_segment_keyword(&self) -> bool
[src]
pub fn is_path_segment_keyword(&self) -> bool
pub fn is_special_ident(&self) -> bool
[src]
pub fn is_special_ident(&self) -> bool
pub fn is_used_keyword(&self) -> bool
[src]
pub fn is_used_keyword(&self) -> bool
Returns true
if the token is a keyword used in the language.
pub fn is_unused_keyword(&self) -> bool
[src]
pub fn is_unused_keyword(&self) -> bool
Returns true
if the token is a keyword reserved for possible future use.
pub fn is_reserved_ident(&self) -> bool
[src]
pub fn is_reserved_ident(&self) -> bool
Returns true
if the token is either a special identifier or a keyword.
pub fn glue(self, joint: Token) -> Option<Token>
[src]
pub fn glue(self, joint: Token) -> Option<Token>
pub fn similar_tokens(&self) -> Option<Vec<Token>>
[src]
pub fn similar_tokens(&self) -> Option<Vec<Token>>
Returns tokens that are likely to be typed accidentally instead of the current token. Enables better error recovery when the wrong token is found.
pub fn interpolated_to_tokenstream(
&self,
sess: &ParseSess,
span: Span
) -> TokenStream
[src]
pub fn interpolated_to_tokenstream(
&self,
sess: &ParseSess,
span: Span
) -> TokenStream
pub fn probably_equal_for_proc_macro(&self, other: &Token) -> bool
[src]
pub fn probably_equal_for_proc_macro(&self, other: &Token) -> bool
Trait Implementations
impl Clone for Token
[src]
impl Clone for Token
fn clone(&self) -> Token
[src]
fn clone(&self) -> Token
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Encodable for Token
[src]
impl Encodable for Token
impl Decodable for Token
[src]
impl Decodable for Token
impl PartialEq for Token
[src]
impl PartialEq for Token
fn eq(&self, other: &Token) -> bool
[src]
fn eq(&self, other: &Token) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Token) -> bool
[src]
fn ne(&self, other: &Token) -> bool
This method tests for !=
.
impl Eq for Token
[src]
impl Eq for Token
impl Hash for Token
[src]
impl Hash for Token
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for Token
[src]
impl Debug for Token
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<Token> for TokenStream
[src]
impl From<Token> for TokenStream
fn from(token: Token) -> TokenStream
[src]
fn from(token: Token) -> TokenStream
Performs the conversion.