Enum harper_core::TokenKind
source · pub enum TokenKind {
Word,
Punctuation(Punctuation),
Number(f64),
Space(usize),
Newline(usize),
}
Variants§
Word
Punctuation(Punctuation)
Number(f64)
Space(usize)
A sequence of “ “ spaces.
Newline(usize)
A sequence of “\n” newlines
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.