pub enum CommentStyle {
Block = 0,
BlockStar = 1,
BlockBang = 2,
BlockPound = 3,
BlockHeading = 4,
Single = 5,
SingleStar = 6,
SingleBang = 7,
}
Expand description
An enum representing the “Style” the Kind::Comment token represents.
A Token with Kind::Comment will store this data internal to the token. Using Token::comment_style() will return this enum, depending on what characters make up the beginning of the comment token. By default the Lexer will only produce multi-line - aka “Block” - comments, but adding Feature::SeparateWhitespace will allow the Lexer to produce single line comments too.
A basic Block comment style uses the /*
leading characters, but sub-styles of the block
style are also computed, for example BlockStar represents a comment using the “double
star” syntax to open the comment, i.e. /**
. Determing if these comments are using these alternate style can help a
parser (or writer) determine if it should retain these comments or otherwise treat them differently to regular block
comments.
use css_lexer::*;
let mut lexer = Lexer::new("/* Normal Comment */ /** Double Star Comment */");
{
// This token will be collapsed Whitespace.
let token = lexer.advance();
assert_eq!(token, Kind::Comment);
assert_eq!(token, CommentStyle::Block);
}
assert_eq!(lexer.advance(), Kind::Whitespace);
{
// This token will be collapsed Whitespace.
let token = lexer.advance();
assert_eq!(token, Kind::Comment);
assert_eq!(token, CommentStyle::BlockStar);
}
Variants§
Block = 0
A basic block comment which uses /*
as the leading style. The third character may be a whitespace, or may
include a character that isn’t !
, #
, =
, -
.
BlockStar = 1
A block comment which uses /**
as the leading style. The two *
s must be adjacent, so this does not count
/* *
.
BlockBang = 2
A block comment which uses /*!
as the leading style. The *
and !
must be adjacent, so this does not count
/* !
.
BlockPound = 3
A block comment which uses /*#
as the leading style. The *
and #
must be adjacent, so this does not count
/* #
.
BlockHeading = 4
A block comment which uses /*=
or /*-
as the leading style. The *
and -
or =
must be adjacent, so this
does not count /* #
.
Single = 5
A basic single line comment which uses //
as the leading style. The third character may be a whitespace, or
may include a character that isn’t *
, !
. The Lexer can only produce a Token
with this style if Feature::SingleLineComments is enabled.
SingleStar = 6
A single line comment which uses //*
as the leading style. The *
be adjacent to the //
, so this does not
count // *
. The Lexer can only produce a Token with this style if
Feature::SingleLineComments is enabled.
SingleBang = 7
A single line comment which uses //!
as the leading style. The !
be adjacent to the //
, so this does not
count // !
. The Lexer can only produce a Token with this style if
Feature::SingleLineComments is enabled.
Implementations§
Trait Implementations§
Source§impl Clone for CommentStyle
impl Clone for CommentStyle
Source§fn clone(&self) -> CommentStyle
fn clone(&self) -> CommentStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CommentStyle
impl Debug for CommentStyle
Source§impl Default for CommentStyle
impl Default for CommentStyle
Source§fn default() -> CommentStyle
fn default() -> CommentStyle
Source§impl Hash for CommentStyle
impl Hash for CommentStyle
Source§impl Ord for CommentStyle
impl Ord for CommentStyle
Source§fn cmp(&self, other: &CommentStyle) -> Ordering
fn cmp(&self, other: &CommentStyle) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq<CommentStyle> for &Cursor
impl PartialEq<CommentStyle> for &Cursor
Source§impl PartialEq<CommentStyle> for Cursor
impl PartialEq<CommentStyle> for Cursor
Source§impl PartialEq<CommentStyle> for SourceCursor<'_>
impl PartialEq<CommentStyle> for SourceCursor<'_>
Source§impl PartialEq<CommentStyle> for Token
impl PartialEq<CommentStyle> for Token
Source§impl PartialEq for CommentStyle
impl PartialEq for CommentStyle
Source§impl PartialOrd for CommentStyle
impl PartialOrd for CommentStyle
Source§impl Serialize for CommentStyle
impl Serialize for CommentStyle
impl Copy for CommentStyle
impl Eq for CommentStyle
impl StructuralPartialEq for CommentStyle
Auto Trait Implementations§
impl Freeze for CommentStyle
impl RefUnwindSafe for CommentStyle
impl Send for CommentStyle
impl Sync for CommentStyle
impl Unpin for CommentStyle
impl UnwindSafe for CommentStyle
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,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more