Skip to content

Commit

Permalink
Merge pull request #1510 from ModProg/patch-3
Browse files Browse the repository at this point in the history
 Add example to `Token!` documentation
  • Loading branch information
dtolnay authored Sep 15, 2023
2 parents 975ce0b + f389836 commit 319433e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,25 @@ define_delimiters! {
/// A type-macro that expands to the name of the Rust type representation of a
/// given token.
///
/// See the [token module] documentation for details and examples.
/// It can expand to the token type and be used to construct a token from a [`Span`]:
/// ```
/// # use syn::{Token};
/// use proc_macro2::Span;
///
/// let fn_token: Token![fn] = Token![fn](Span::call_site());
/// ```
/// It can be used with [`ParseBuffer::peek`]:
/// ```
/// # use syn::{Token, parse::ParseStream};
/// # fn parser(input: ParseStream) {
/// input.peek(Token![<<]);
/// # }
/// ```
///
/// See the [token module] documentation for details and more examples.
///
/// [token module]: crate::token
/// [`ParseBuffer::peek`]: crate::parse::ParseBuffer::peek
#[macro_export]
macro_rules! Token {
[abstract] => { $crate::token::Abstract };
Expand Down

0 comments on commit 319433e

Please sign in to comment.