pub struct KindSet(/* private fields */);
Expand description
Match a token against one or more Kinds.
Each Kind represents the token “type”. KindSet is a bitmask of all possible Kinds. This is useful for efficiently comparing a token to see if it matches N token Kinds.
§Example
use css_lexer::*;
let mut lexer = Lexer::new("width: 1px");
// The first token is either an AtKeyword, Ident or Function:
assert_eq!(lexer.advance(), KindSet::new(&[Kind::AtKeyword, Kind::Ident, Kind::Function]));
Implementations§
Source§impl KindSet
impl KindSet
Sourcepub const TRIVIA: KindSet
pub const TRIVIA: KindSet
A KindSet that matches all trivia; Kind::Whitespace and Kind::Comment.
Sourcepub const WHITESPACE: KindSet
pub const WHITESPACE: KindSet
A KindSet that matches just Whitespace. This is the same as Kind::Whitespace but can be useful to apply to functions that expect a KindSet rather than Kind.
Sourcepub const COMMENTS: KindSet
pub const COMMENTS: KindSet
A KindSet that matches just Whitespace. This is the same as Kind::Comment but can be useful to apply to functions that expect a KindSet rather than Kind.
Sourcepub const RIGHT_CURLY_OR_SEMICOLON: KindSet
pub const RIGHT_CURLY_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::RightCurly or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a declaration.
Sourcepub const LEFT_CURLY_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of an at-rule prelude.
Sourcepub const LEFT_CURLY_RIGHT_PAREN_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_RIGHT_PAREN_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::RightParen or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a function.
Sourcepub const LEFT_CURLY_RIGHT_PAREN_COMMA_OR_SEMICOLON: KindSet
pub const LEFT_CURLY_RIGHT_PAREN_COMMA_OR_SEMICOLON: KindSet
A KindSet that matches either Kind::LeftCurly or Kind::RightParen or Kind::Comma or Kind::Semicolon. This is useful for matching stop-tokens, for example checking the end of a function or Selector.
Sourcepub const DELIM_LIKE: KindSet
pub const DELIM_LIKE: KindSet
A KindSet that matches any single character token, such as Kind::Delim or Kind::Colon - Kind::RightCurly.
Trait Implementations§
Source§impl From<SourceCursor<'_>> for KindSet
impl From<SourceCursor<'_>> for KindSet
Source§fn from(cursor: SourceCursor<'_>) -> Self
fn from(cursor: SourceCursor<'_>) -> Self
Source§impl Ord for KindSet
impl Ord for KindSet
Source§impl PartialEq<KindSet> for SourceCursor<'_>
impl PartialEq<KindSet> for SourceCursor<'_>
Source§impl PartialOrd for KindSet
impl PartialOrd for KindSet
impl Copy for KindSet
impl Eq for KindSet
impl StructuralPartialEq for KindSet
Auto Trait Implementations§
impl Freeze for KindSet
impl RefUnwindSafe for KindSet
impl Send for KindSet
impl Sync for KindSet
impl Unpin for KindSet
impl UnwindSafe for KindSet
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