Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example to Token! documentation #1510

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`]:
/// ```
ModProg marked this conversation as resolved.
Show resolved Hide resolved
/// # 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