pub struct Whitespace { /* private fields */ }Expand description
A bitmask 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 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 the 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(&EmptyAtomSet::ATOMS, "\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§
Source§impl Whitespace
impl Whitespace
Sourcepub const Space: Whitespace
pub const Space: Whitespace
The whitespace token contains at least 1 Space ( ) character.
Sourcepub const Tab: Whitespace
pub const Tab: Whitespace
The whitespace token contains at least 1 Tab (\t) character.
Sourcepub 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.
Sourcepub const fn all_bits() -> Self
pub const fn all_bits() -> Self
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.
Sourcepub 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
Sourcepub 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.
Sourcepub const fn all() -> Self
👎Deprecated: Please use the ::all_bits() constructor
pub const fn all() -> Self
::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.
Sourcepub 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
Sourcepub const fn full() -> Self
👎Deprecated: Please use the ::all_flags() constructor
pub const fn full() -> Self
::all_flags() constructorReturns a bitmask that contains all flags.
Sourcepub 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.
Sourcepub const fn truncate(&self) -> Self
pub const fn truncate(&self) -> Self
Returns a bitmask that only has bits corresponding to flags
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> 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.
Trait Implementations§
Source§impl Binary for Whitespace
impl Binary for Whitespace
Source§impl BitAnd for Whitespace
impl BitAnd for Whitespace
Source§impl BitAndAssign for Whitespace
impl BitAndAssign for Whitespace
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOr for Whitespace
impl BitOr for Whitespace
Source§impl BitOrAssign for Whitespace
impl BitOrAssign for Whitespace
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXor for Whitespace
impl BitXor for Whitespace
Source§impl BitXorAssign for Whitespace
impl BitXorAssign for Whitespace
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl Clone for Whitespace
impl Clone for Whitespace
Source§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