From f38983680dfcdaa82c317176518ba739a5f42b1b Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Thu, 14 Sep 2023 11:39:45 +0200 Subject: [PATCH] Add example to `Token!` documentation This allows rust-analyzer to correctly complete the preferred brackets, instead of parenthesis. --- src/token.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/token.rs b/src/token.rs index c7e0e1f1a6..1981323008 100644 --- a/src/token.rs +++ b/src/token.rs @@ -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 };