Struct Punct

struct Punct(_)

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.

Implementations

impl Punct

fn new(ch: char, spacing: Spacing) -> Punct

Creates a new Punct from the given character and spacing. The ch argument must be a valid punctuation character permitted by the language, otherwise the function will panic.

The returned Punct will have the default span of Span::call_site() which can be further configured with the set_span method below.

fn as_char(self: &Self) -> char

Returns the value of this punctuation character as char.

fn spacing(self: &Self) -> Spacing

Returns the spacing of this punctuation character, indicating whether it can be potentially combined into a multi-character operator with the following token (Joint), or whether the operator has definitely ended (Alone).

fn span(self: &Self) -> Span

Returns the span for this punctuation character.

fn set_span(self: &mut Self, span: Span)

Configure the span for this punctuation character.

impl Clone for Punct

fn clone(self: &Self) -> Punct

impl Debug for Punct

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

impl Display for Punct

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

impl Freeze for Punct

impl PartialEq for Punct

fn eq(self: &Self, rhs: &char) -> bool

impl RefUnwindSafe for Punct

impl Send for Punct

impl Sync for Punct

impl ToTokens for crate::Punct

fn to_tokens(self: &Self, tokens: &mut TokenStream)

impl Unpin for Punct

impl UnwindSafe for Punct

impl<T> Any for Punct

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Punct

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

impl<T> BorrowMut for Punct

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

impl<T> CloneToUninit for Punct

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

impl<T> From for Punct

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Punct

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

impl<T> ToString for Punct

fn to_string(self: &Self) -> String

impl<T, U> Into for Punct

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 Punct

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

impl<T, U> TryInto for Punct

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