Struct Punct

pub struct Punct { /* private fields */ }

A Punct is a single punctuation character like +, - or #.

Multicharacter operators like += are represented as two instances of Punct with different forms of Spacing returned.

Implementations

impl Punct

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

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) -> char

Returns the value of this punctuation character as char.

fn spacing(&self) -> Spacing

Returns the spacing of this punctuation character, indicating whether it's immediately followed by another Punct in the token stream, so they can potentially be combined into a multicharacter operator (Joint), or it's followed by some other token or whitespace (Alone) so the operator has certainly ended.

fn span(&self) -> Span

Returns the span for this punctuation character.

fn set_span(&mut self, span: Span)

Configure the span for this punctuation character.

Trait Implementations

impl Clone for Punct

fn clone(&self) -> Self

impl Debug for Punct

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

impl Display for Punct

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

Auto Trait Implementations

impl !Send for Punct

impl !Sync for Punct

impl Freeze for Punct

impl RefUnwindSafe for Punct

impl Unpin for Punct

impl UnsafeUnpin for Punct

impl UnwindSafe for Punct

Blanket Implementations

impl<T> Any for Punct where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Punct where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Punct where T: ?Sized,

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

impl<T> CloneToUninit for Punct where T: Clone,

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

impl<T> From<T> for Punct

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Punct where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for Punct where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for Punct where U: From<T>,

fn into(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<U> for Punct where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Punct where U: TryFrom<T>,

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