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

Improve proc_macro::{Punct, Spacing} documentation #86495

Merged
merged 1 commit into from
Jun 21, 2021
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
15 changes: 9 additions & 6 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ impl fmt::Debug for Group {
}
}

/// An `Punct` is an single punctuation character like `+`, `-` or `#`.
/// A `Punct` is a single punctuation character such as `+`, `-` or `#`.
///
/// Multi-character operators like `+=` are represented as two instances of `Punct` with different
/// forms of `Spacing` returned.
Expand All @@ -779,16 +779,19 @@ impl !Send for Punct {}
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl !Sync for Punct {}

/// Whether an `Punct` is followed immediately by another `Punct` or
/// followed by another token or whitespace.
/// Describes whether a `Punct` is followed immediately by another `Punct` ([`Spacing::Joint`]) or
/// by a different token or whitespace ([`Spacing::Alone`]).
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
pub enum Spacing {
/// e.g., `+` is `Alone` in `+ =`, `+ident` or `+()`.
/// A `Punct` is not immediately followed by another `Punct`.
/// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`.
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Alone,
/// e.g., `+` is `Joint` in `+=` or `'#`.
/// Additionally, single quote `'` can join with identifiers to form lifetimes `'ident`.
/// A `Punct` is immediately followed by another `Punct`.
/// E.g. `+` is `Joint` in `+=` and `++`.
///
/// Additionally, single quote `'` can join with identifiers to form lifetimes: `'ident`.
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Joint,
}
Expand Down