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
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, &Option<NumberSuffix>)>
pub fn as_number(&self) -> Option<(&f64, &Option<NumberSuffix>)>
Returns Some
if self
is a reference of variant Number
, and None
otherwise.
sourcepub fn as_mut_number(&mut self) -> Option<(&mut f64, &mut Option<NumberSuffix>)>
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.
sourcepub fn expect_number(self) -> (f64, Option<NumberSuffix>)where
Self: Debug,
pub fn expect_number(self) -> (f64, Option<NumberSuffix>)where
Self: Debug,
sourcepub fn number(self) -> Option<(f64, Option<NumberSuffix>)>
pub fn number(self) -> Option<(f64, Option<NumberSuffix>)>
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_email_address(&self) -> bool
pub const fn is_email_address(&self) -> bool
Returns true
if self
is of variant EmailAddress
.
sourcepub const fn is_hostname(&self) -> bool
pub const fn is_hostname(&self) -> bool
Returns true
if self
is of variant Hostname
.
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 moreimpl Copy for TokenKind
impl StructuralPartialEq for TokenKind
Auto Trait Implementations§
impl Freeze for TokenKind
impl RefUnwindSafe for TokenKind
impl Send for TokenKind
impl Sync for TokenKind
impl Unpin for TokenKind
impl UnwindSafe for TokenKind
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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