Enum Spacing

enum Spacing

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, the compiler will only set spacing to Joint in the following cases.

  • When a Punct is immediately followed by another Punct without a whitespace. E.g. + is Joint in += and ++.
  • When a single quote ' is immediately followed by an identifier without a whitespace. E.g. ' is Joint 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, the 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, tokens not followed by anything will be marked as Alone.

Implementations

impl Clone for Spacing

fn clone(self: &Self) -> Spacing

impl Copy for Spacing

impl Debug for Spacing

fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result

impl Eq for Spacing

impl Freeze for Spacing

impl PartialEq for Spacing

fn eq(self: &Self, other: &Spacing) -> bool

impl RefUnwindSafe for Spacing

impl Send for Spacing

impl StructuralPartialEq for Spacing

impl Sync for Spacing

impl Unpin for Spacing

impl UnwindSafe for Spacing

impl<T> Any for Spacing

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Spacing

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Spacing

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Spacing

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Spacing

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Spacing

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Spacing

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Spacing

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Spacing

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>