harper_core

Enum TokenKind

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

Variants§

§

Word(WordMetadata)

§

Punctuation(Punctuation)

§

Number(OrderedFloat<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.

§

ParagraphBreak

Implementations§

source§

impl TokenKind

source

pub const fn is_word(&self) -> bool

Returns true if self is of variant Word.

source

pub fn as_word(&self) -> Option<&WordMetadata>

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

source

pub fn as_mut_word(&mut self) -> Option<&mut WordMetadata>

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

source

pub fn expect_word(self) -> WordMetadata
where Self: Debug,

Unwraps the value, yielding the content of Word.

§Panics

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

source

pub fn word(self) -> Option<WordMetadata>

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

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<(&OrderedFloat<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 OrderedFloat<f64>, &mut Option<NumberSuffix>)>

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

source

pub fn expect_number(self) -> (OrderedFloat<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<(OrderedFloat<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

pub const fn is_paragraph_break(&self) -> bool

Returns true if self is of variant ParagraphBreak.

source§

impl TokenKind

source

pub fn is_open_square(&self) -> bool

source

pub fn is_close_square(&self) -> bool

source

pub fn is_pipe(&self) -> bool

source

pub fn is_pronoun(&self) -> bool

source

pub fn is_conjunction(&self) -> bool

source

pub fn is_ellipsis(&self) -> bool

source

pub fn is_swear(&self) -> bool

source

pub fn matches_variant_of(&self, other: &Self) -> bool

Checks that self is the same enum variant as other, regardless of whether the inner metadata is also equal.

source

pub fn with_default_data(&self) -> Self

Produces a copy of self with any inner data replaced with it’s default value. Useful for making comparisons on just the variant of the enum.

source§

impl TokenKind

source

pub fn blank_word() -> Self

Construct a TokenKind::Word with no (default) metadata.

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_quote(&self) -> bool

source

pub fn is_apostrophe(&self) -> bool

source

pub fn is_period(&self) -> bool

source

pub fn is_at(&self) -> bool

source

pub fn is_case_separator(&self) -> bool

Used by crate::parsers::CollapseIdentifiers TODO: Separate this into two functions and add OR functionality to pattern matching

source

pub fn is_verb(&self) -> bool

source

pub fn is_linking_verb(&self) -> bool

source

pub fn is_noun(&self) -> bool

source

pub fn is_comma(&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 Hash for TokenKind

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for TokenKind

source§

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

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

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

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

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

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

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

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 Eq 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

source§

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>,

source§

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>,

source§

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>,