pub enum Token {
Ident {
name: String,
span: Span,
},
Group {
delimiter: Delimiter,
stream: MacroStream,
span: Span,
},
Literal {
kind: LiteralKind,
value: String,
span: Span,
suffix: String,
token: Option<Literal>,
},
Punctuation {
value: char,
spacing: Spacing,
span: Span,
},
}
Expand description
A token in a macro.
Variants§
Ident
Group
Literal
Punctuation
either a single character for something like +
or a longer string for something like +=
or +===
Implementations§
Source§impl Token
impl Token
pub fn to_token_stream(&self) -> TokenStream
pub fn from_tokens(queue: &mut VecDeque<TokenTree>) -> ParseResult<Self>
pub fn ident(&self) -> Option<&str>
pub fn group(&self) -> Option<&MacroStream>
pub fn lit_suffix(&self) -> Option<&str>
pub fn span(&self) -> Span
pub fn punctuation(&self) -> Option<&char>
pub fn lit_byte(&self) -> Option<u8>
pub fn lit_char(&self) -> Option<char>
pub fn lit_integer<I>(&self) -> Option<I>where
I: FromStr,
pub fn lit_float<F>(&self) -> Option<F>where
F: FromStr,
pub fn lit_str(&self) -> Option<&str>
pub fn lit_str_raw(&self) -> Option<&str>
pub fn lit_byte_str(&self) -> Option<&[u8]>
pub fn lit_byte_str_raw(&self) -> Option<&[u8]>
Trait Implementations§
Source§impl ToTokens for Token
Note: Converting a Literal will result in the loss of the suffix and typically also specific information regarding what type it is, the value itself will not be lost (large u128 numbers exceeding 127 bits may lose their last bit though).
impl ToTokens for Token
Note: Converting a Literal will result in the loss of the suffix and typically also specific information regarding what type it is, the value itself will not be lost (large u128 numbers exceeding 127 bits may lose their last bit though).
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl Eq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl !Send for Token
impl !Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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