Enum harper_core::TokenKind
source · pub enum TokenKind {
Word,
Punctuation(Punctuation),
Number(f64),
Space(usize),
Newline(usize),
Unlintable,
}Variants§
Word
Punctuation(Punctuation)
Number(f64)
Space(usize)
A sequence of “ “ spaces.
Newline(usize)
A sequence of “\n” newlines
Unlintable
A special token used for things like inline code blocks that should be ignored by all linters.
Implementations§
source§impl TokenKind
impl TokenKind
sourcepub const fn is_punctuation(&self) -> bool
pub const fn is_punctuation(&self) -> bool
Returns true if self is of variant Punctuation.
sourcepub fn as_punctuation(&self) -> Option<&Punctuation>
pub fn as_punctuation(&self) -> Option<&Punctuation>
Returns Some if self is a reference of variant Punctuation, and None otherwise.
sourcepub fn as_mut_punctuation(&mut self) -> Option<&mut Punctuation>
pub fn as_mut_punctuation(&mut self) -> Option<&mut Punctuation>
Returns Some if self is a mutable reference of variant Punctuation, and None otherwise.
sourcepub fn expect_punctuation(self) -> Punctuationwhere
Self: Debug,
pub fn expect_punctuation(self) -> Punctuationwhere
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.
sourcepub fn punctuation(self) -> Option<Punctuation>
pub fn punctuation(self) -> Option<Punctuation>
Returns Some if self is of variant Punctuation, and None otherwise.
sourcepub fn as_number(&self) -> Option<&f64>
pub fn as_number(&self) -> Option<&f64>
Returns Some if self is a reference of variant Number, and None otherwise.
sourcepub fn as_mut_number(&mut self) -> Option<&mut f64>
pub fn as_mut_number(&mut self) -> Option<&mut f64>
Returns Some if self is a mutable reference of variant Number, and None otherwise.
sourcepub fn expect_number(self) -> f64where
Self: Debug,
pub fn expect_number(self) -> f64where
Self: Debug,
sourcepub fn number(self) -> Option<f64>
pub fn number(self) -> Option<f64>
Returns Some if self is of variant Number, and None otherwise.
sourcepub fn as_space(&self) -> Option<&usize>
pub fn as_space(&self) -> Option<&usize>
Returns Some if self is a reference of variant Space, and None otherwise.
sourcepub fn as_mut_space(&mut self) -> Option<&mut usize>
pub fn as_mut_space(&mut self) -> Option<&mut usize>
Returns Some if self is a mutable reference of variant Space, and None otherwise.
sourcepub fn expect_space(self) -> usizewhere
Self: Debug,
pub fn expect_space(self) -> usizewhere
Self: Debug,
sourcepub fn space(self) -> Option<usize>
pub fn space(self) -> Option<usize>
Returns Some if self is of variant Space, and None otherwise.
sourcepub const fn is_newline(&self) -> bool
pub const fn is_newline(&self) -> bool
Returns true if self is of variant Newline.
sourcepub fn as_newline(&self) -> Option<&usize>
pub fn as_newline(&self) -> Option<&usize>
Returns Some if self is a reference of variant Newline, and None otherwise.
sourcepub fn as_mut_newline(&mut self) -> Option<&mut usize>
pub fn as_mut_newline(&mut self) -> Option<&mut usize>
Returns Some if self is a mutable reference of variant Newline, and None otherwise.
sourcepub fn expect_newline(self) -> usizewhere
Self: Debug,
pub fn expect_newline(self) -> usizewhere
Self: Debug,
sourcepub fn newline(self) -> Option<usize>
pub fn newline(self) -> Option<usize>
Returns Some if self is of variant Newline, and None otherwise.
sourcepub const fn is_unlintable(&self) -> bool
pub const fn is_unlintable(&self) -> bool
Returns true if self is of variant Unlintable.
Trait Implementations§
source§impl<'de> Deserialize<'de> for TokenKind
impl<'de> Deserialize<'de> for TokenKind
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for TokenKind
impl PartialEq for TokenKind
source§impl PartialOrd for TokenKind
impl PartialOrd for TokenKind
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more