Enum proc_macro::Spacing
1.29.0 · source · pub enum Spacing {
Joint,
Alone,
}
Expand description
Indicates whether a Punct
token can join with the following token
to form a multi-character operator.
Variants§
Joint
A Punct
token can join with the following token to form a multi-character operator.
In token streams constructed using proc macro interfaces Joint
punctuation tokens can be
followed by any other tokens.
However, in token streams parsed from source code compiler will only set spacing to Joint
in the following cases:
- A
Punct
is immediately followed by anotherPunct
without a whitespace.
E.g.+
isJoint
in+=
and++
. - A single quote
'
is immediately followed by an identifier without a whitespace.
E.g.'
isJoint
in'lifetime
.
This list may be extended in the future to enable more token combinations.
Alone
A Punct
token cannot join with the following token to form a multi-character operator.
Alone
punctuation tokens can be followed by any other tokens.
In token streams parsed from source code compiler will set spacing to Alone
in all cases
not covered by the conditions for Joint
above.
E.g. +
is Alone
in + =
, +ident
and +()
.
In particular, token not followed by anything will also be marked as Alone
.