Struct Whitespace
pub struct Whitespace { /* private fields */ }
Expand description
A [bitmask][bitmask_enum] representing the characters that make up a Kind::Whitespace token.
A Token with Kind::Whitespace will store this data internal to the token. Using Token::whitespace_style() will return this bitmask, depending on what characters make up the whitespace token. By default the [Lexer][crate::Lexer] will produce combine multiple whitespaces into a single Token, so it is possible that Token::whitespace_style() could contain all of the available bits here. With [Feature::SeparateWhitespace][crate::Feature::SeparateWhitespace] the [Lexer][crate::Lexer] will produce discrete tokens each which can only have one of the available bits in this bitmask.
use css_lexer::*;
let mut lexer = Lexer::new("\n\t");
{
// This token will be collapsed Whitespace.
let token = lexer.advance();
assert_eq!(token, Kind::Whitespace);
// The Whitespace is comprised of many bits:
assert_eq!(token, Whitespace::Newline | Whitespace::Tab);
}
Implementations§
§impl Whitespace
impl Whitespace
pub const Space: Whitespace
pub const Space: Whitespace
The whitespace token contains at least 1 Space (
) character.
pub const Tab: Whitespace
pub const Tab: Whitespace
The whitespace token contains at least 1 Tab (\t
) character.
pub const Newline: Whitespace
pub const Newline: Whitespace
The whitespace token contains at least 1 Newline (\n
) or newline-adjacent (\r
, \r\n
, \u{c}
) character.
pub const fn all_bits() -> Whitespace
pub const fn all_bits() -> Whitespace
Returns a bitmask that contains all values.
This will include bits that do not have any flags.
Use ::all_flags()
if you only want to use flags.
pub const fn all_flags() -> Whitespace
pub const fn all_flags() -> Whitespace
Returns a bitmask that contains all flags.
pub const fn is_all_bits(&self) -> bool
pub const fn is_all_bits(&self) -> bool
Returns true
if the bitmask contains all values.
This will check for bits == !0
,
use .is_all_flags()
if you only want to check for all flags
pub const fn is_all_flags(&self) -> bool
pub const fn is_all_flags(&self) -> bool
Returns true
if the bitmask contains all flags.
This will fail if any unused bit is set,
consider using .truncate()
first.
pub const fn all() -> Whitespace
👎Deprecated: Please use the ::all_bits()
constructor
pub const fn all() -> Whitespace
::all_bits()
constructorReturns a bitmask that contains all values.
This will include bits that do not have any flags.
Use ::all_flags()
if you only want to use flags.
pub const fn is_all(&self) -> bool
👎Deprecated: Please use the .is_all_bits()
method
pub const fn is_all(&self) -> bool
.is_all_bits()
methodReturns true
if the bitmask contains all values.
This will check for bits == !0
,
use .is_all_flags()
if you only want to check for all flags
pub const fn full() -> Whitespace
👎Deprecated: Please use the ::all_flags()
constructor
pub const fn full() -> Whitespace
::all_flags()
constructorReturns a bitmask that contains all flags.
pub const fn is_full(&self) -> bool
👎Deprecated: Please use the .is_all_flags()
method
pub const fn is_full(&self) -> bool
.is_all_flags()
methodReturns true
if the bitmask contains all flags.
This will fail if any unused bit is set,
consider using .truncate()
first.
pub const fn none() -> Whitespace
pub const fn none() -> Whitespace
Returns a bitmask that does not contain any values.
pub const fn truncate(&self) -> Whitespace
pub const fn truncate(&self) -> Whitespace
Returns a bitmask that only has bits corresponding to flags
pub const fn intersects(&self, other: Whitespace) -> bool
pub const fn intersects(&self, other: Whitespace) -> bool
Returns true
if self
intersects with any value in other
,
or if other
does not contain any values.
This is equivalent to (self & other) != 0 || other == 0
.
pub const fn contains(&self, other: Whitespace) -> bool
pub const fn contains(&self, other: Whitespace) -> bool
Returns true
if self
contains all values of other
.
This is equivalent to (self & other) == other
.
pub const fn not(self) -> Whitespace
pub const fn not(self) -> Whitespace
Returns the bitwise NOT of the bitmask.
pub const fn and(self, other: Whitespace) -> Whitespace
pub const fn and(self, other: Whitespace) -> Whitespace
Returns the bitwise AND of the bitmask.
pub const fn or(self, other: Whitespace) -> Whitespace
pub const fn or(self, other: Whitespace) -> Whitespace
Returns the bitwise OR of the bitmask.
pub const fn xor(self, other: Whitespace) -> Whitespace
pub const fn xor(self, other: Whitespace) -> Whitespace
Returns the bitwise XOR of the bitmask.
Trait Implementations§
§impl Binary for Whitespace
impl Binary for Whitespace
§impl BitAnd for Whitespace
impl BitAnd for Whitespace
§type Output = Whitespace
type Output = Whitespace
&
operator.§fn bitand(self, rhs: Whitespace) -> <Whitespace as BitAnd>::Output
fn bitand(self, rhs: Whitespace) -> <Whitespace as BitAnd>::Output
&
operation. Read more§impl BitAndAssign for Whitespace
impl BitAndAssign for Whitespace
§fn bitand_assign(&mut self, rhs: Whitespace)
fn bitand_assign(&mut self, rhs: Whitespace)
&=
operation. Read more§impl BitOr for Whitespace
impl BitOr for Whitespace
§type Output = Whitespace
type Output = Whitespace
|
operator.§fn bitor(self, rhs: Whitespace) -> <Whitespace as BitOr>::Output
fn bitor(self, rhs: Whitespace) -> <Whitespace as BitOr>::Output
|
operation. Read more§impl BitOrAssign for Whitespace
impl BitOrAssign for Whitespace
§fn bitor_assign(&mut self, rhs: Whitespace)
fn bitor_assign(&mut self, rhs: Whitespace)
|=
operation. Read more§impl BitXor for Whitespace
impl BitXor for Whitespace
§type Output = Whitespace
type Output = Whitespace
^
operator.§fn bitxor(self, rhs: Whitespace) -> <Whitespace as BitXor>::Output
fn bitxor(self, rhs: Whitespace) -> <Whitespace as BitXor>::Output
^
operation. Read more§impl BitXorAssign for Whitespace
impl BitXorAssign for Whitespace
§fn bitxor_assign(&mut self, rhs: Whitespace)
fn bitxor_assign(&mut self, rhs: Whitespace)
^=
operation. Read more§impl Clone for Whitespace
impl Clone for Whitespace
§fn clone(&self) -> Whitespace
fn clone(&self) -> Whitespace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for Whitespace
impl Debug for Whitespace
§impl From<Token> for Whitespace
impl From<Token> for Whitespace
§fn from(token: Token) -> Whitespace
fn from(token: Token) -> Whitespace
§impl From<u8> for Whitespace
impl From<u8> for Whitespace
§fn from(val: u8) -> Whitespace
fn from(val: u8) -> Whitespace
§impl Hash for Whitespace
impl Hash for Whitespace
§impl LowerHex for Whitespace
impl LowerHex for Whitespace
§impl Not for Whitespace
impl Not for Whitespace
§type Output = Whitespace
type Output = Whitespace
!
operator.§impl Octal for Whitespace
impl Octal for Whitespace
§impl Ord for Whitespace
impl Ord for Whitespace
§impl PartialEq<Whitespace> for Token
impl PartialEq<Whitespace> for Token
§impl PartialEq<u8> for Whitespace
impl PartialEq<u8> for Whitespace
§impl PartialEq for Whitespace
impl PartialEq for Whitespace
§impl PartialOrd for Whitespace
impl PartialOrd for Whitespace
§impl UpperHex for Whitespace
impl UpperHex for Whitespace
impl Copy for Whitespace
impl Eq for Whitespace
impl StructuralPartialEq for Whitespace
Auto Trait Implementations§
impl Freeze for Whitespace
impl RefUnwindSafe for Whitespace
impl Send for Whitespace
impl Sync for Whitespace
impl Unpin for Whitespace
impl UnwindSafe for Whitespace
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