Enum harper_core::TokenKind

source ·
pub enum TokenKind {
    Word,
    Punctuation(Punctuation),
    Number(f64, Option<NumberSuffix>),
    Space(usize),
    Newline(usize),
    EmailAddress,
    Url,
    Hostname,
    Unlintable,
}

Variants§

§

Word

§

Punctuation(Punctuation)

§

Number(f64, Option<NumberSuffix>)

§

Space(usize)

A sequence of “ “ spaces.

§

Newline(usize)

A sequence of “\n” newlines

§

EmailAddress

§

Url

§

Hostname

§

Unlintable

A special token used for things like inline code blocks that should be ignored by all linters.

Implementations§

source§

impl TokenKind

source

pub const fn is_word(&self) -> bool

Returns true if self is of variant Word.

source

pub const fn is_punctuation(&self) -> bool

Returns true if self is of variant Punctuation.

source

pub fn as_punctuation(&self) -> Option<&Punctuation>

Returns Some if self is a reference of variant Punctuation, and None otherwise.

source

pub fn as_mut_punctuation(&mut self) -> Option<&mut Punctuation>

Returns Some if self is a mutable reference of variant Punctuation, and None otherwise.

source

pub fn expect_punctuation(self) -> Punctuation
where Self: Debug,

Unwraps the value, yielding the content of Punctuation.

§Panics

Panics if the value is not Punctuation, with a panic message including the content of self.

source

pub fn punctuation(self) -> Option<Punctuation>

Returns Some if self is of variant Punctuation, and None otherwise.

source

pub const fn is_number(&self) -> bool

Returns true if self is of variant Number.

source

pub fn as_number(&self) -> Option<(&f64, &Option<NumberSuffix>)>

Returns Some if self is a reference of variant Number, and None otherwise.

source

pub fn as_mut_number(&mut self) -> Option<(&mut f64, &mut Option<NumberSuffix>)>

Returns Some if self is a mutable reference of variant Number, and None otherwise.

source

pub fn expect_number(self) -> (f64, Option<NumberSuffix>)
where Self: Debug,

Unwraps the value, yielding the content of Number.

§Panics

Panics if the value is not Number, with a panic message including the content of self.

source

pub fn number(self) -> Option<(f64, Option<NumberSuffix>)>

Returns Some if self is of variant Number, and None otherwise.

source

pub const fn is_space(&self) -> bool

Returns true if self is of variant Space.

source

pub fn as_space(&self) -> Option<&usize>

Returns Some if self is a reference of variant Space, and None otherwise.

source

pub fn as_mut_space(&mut self) -> Option<&mut usize>

Returns Some if self is a mutable reference of variant Space, and None otherwise.

source

pub fn expect_space(self) -> usize
where Self: Debug,

Unwraps the value, yielding the content of Space.

§Panics

Panics if the value is not Space, with a panic message including the content of self.

source

pub fn space(self) -> Option<usize>

Returns Some if self is of variant Space, and None otherwise.

source

pub const fn is_newline(&self) -> bool

Returns true if self is of variant Newline.

source

pub fn as_newline(&self) -> Option<&usize>

Returns Some if self is a reference of variant Newline, and None otherwise.

source

pub fn as_mut_newline(&mut self) -> Option<&mut usize>

Returns Some if self is a mutable reference of variant Newline, and None otherwise.

source

pub fn expect_newline(self) -> usize
where Self: Debug,

Unwraps the value, yielding the content of Newline.

§Panics

Panics if the value is not Newline, with a panic message including the content of self.

source

pub fn newline(self) -> Option<usize>

Returns Some if self is of variant Newline, and None otherwise.

source

pub const fn is_email_address(&self) -> bool

Returns true if self is of variant EmailAddress.

source

pub const fn is_url(&self) -> bool

Returns true if self is of variant Url.

source

pub const fn is_hostname(&self) -> bool

Returns true if self is of variant Hostname.

source

pub const fn is_unlintable(&self) -> bool

Returns true if self is of variant Unlintable.

source§

impl TokenKind

source

pub fn as_mut_quote(&mut self) -> Option<&mut Quote>

source

pub fn as_quote(&self) -> Option<&Quote>

source

pub fn is_apostrophe(&self) -> bool

source

pub fn is_whitespace(&self) -> bool

Checks whether the token is whitespace.

Trait Implementations§

source§

impl Clone for TokenKind

source§

fn clone(&self) -> TokenKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TokenKind

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for TokenKind

source§

fn default() -> TokenKind

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for TokenKind

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for TokenKind

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for TokenKind

source§

fn partial_cmp(&self, other: &TokenKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for TokenKind

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for TokenKind

source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,