Enum harper_core::parsers::TokenKind
source · pub enum TokenKind {
Word(WordMetadata),
Punctuation(Punctuation),
Number(f64, Option<NumberSuffix>),
Space(usize),
Newline(usize),
EmailAddress,
Url,
Hostname,
Unlintable,
ParagraphBreak,
}
Variants§
Word(WordMetadata)
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.
ParagraphBreak
Implementations§
source§impl TokenKind
impl TokenKind
sourcepub fn as_word(&self) -> Option<&WordMetadata>
pub fn as_word(&self) -> Option<&WordMetadata>
Returns Some
if self
is a reference of variant Word
, and None
otherwise.
sourcepub fn as_mut_word(&mut self) -> Option<&mut WordMetadata>
pub fn as_mut_word(&mut self) -> Option<&mut WordMetadata>
Returns Some
if self
is a mutable reference of variant Word
, and None
otherwise.
sourcepub fn expect_word(self) -> WordMetadatawhere
Self: Debug,
pub fn expect_word(self) -> WordMetadatawhere
Self: Debug,
sourcepub fn word(self) -> Option<WordMetadata>
pub fn word(self) -> Option<WordMetadata>
Returns Some
if self
is of variant Word
, and None
otherwise.
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
.
sourcepub const fn is_paragraph_break(&self) -> bool
pub const fn is_paragraph_break(&self) -> bool
Returns true
if self
is of variant ParagraphBreak
.
source§impl TokenKind
impl TokenKind
sourcepub fn blank_word() -> Self
pub fn blank_word() -> Self
Construct a TokenKind::Word
with no metadata.
source§impl TokenKind
impl TokenKind
pub fn as_mut_quote(&mut self) -> Option<&mut Quote>
pub fn as_quote(&self) -> Option<&Quote>
pub fn is_quote(&self) -> bool
pub fn is_apostrophe(&self) -> bool
pub fn is_period(&self) -> bool
pub fn is_at(&self) -> bool
sourcepub fn is_whitespace(&self) -> bool
pub fn is_whitespace(&self) -> bool
Checks whether the token is whitespace.
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 PartialOrd for TokenKind
impl PartialOrd for TokenKind
impl 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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