This commit is contained in:
Connor Skees 2021-07-03 18:46:22 -04:00
parent e5d73ac265
commit b631ad78bc
5 changed files with 40 additions and 14 deletions

View File

@ -99,8 +99,12 @@ impl<'a> Parser<'a> {
value += as_hex(next.kind);
self.toks.next();
}
if matches!(self.toks.peek(), Some(Token { kind: ' ', .. }) | Some(Token { kind: '\n', .. }) | Some(Token { kind: '\t', .. }))
{
if matches!(
self.toks.peek(),
Some(Token { kind: ' ', .. })
| Some(Token { kind: '\n', .. })
| Some(Token { kind: '\t', .. })
) {
self.toks.next();
}
} else {

View File

@ -68,10 +68,12 @@ impl<'a> Parser<'a> {
self.expect_char(':')?;
self.whitespace_or_comment();
let value = self.parse_value(
false,
&|toks| matches!(toks.peek(), Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }))
)?;
let value = self.parse_value(false, &|toks| {
matches!(
toks.peek(),
Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. })
)
})?;
config.insert(name.map_node(|n| n.into()), value)?;

View File

@ -205,16 +205,20 @@ impl<'a> Parser<'a> {
match self.toks.peek() {
Some(Token { kind: 'i', .. }) | Some(Token { kind: 'I', .. }) => {
self.toks.advance_cursor();
if !matches!(self.toks.peek(), Some(Token { kind: 'n', .. }) | Some(Token { kind: 'N', .. }))
{
if !matches!(
self.toks.peek(),
Some(Token { kind: 'n', .. }) | Some(Token { kind: 'N', .. })
) {
return Ok(None);
}
buf.push_str("min(")
}
Some(Token { kind: 'a', .. }) | Some(Token { kind: 'A', .. }) => {
self.toks.advance_cursor();
if !matches!(self.toks.peek(), Some(Token { kind: 'x', .. }) | Some(Token { kind: 'X', .. }))
{
if !matches!(
self.toks.peek(),
Some(Token { kind: 'x', .. }) | Some(Token { kind: 'X', .. })
) {
return Ok(None);
}
buf.push_str("max(")
@ -377,8 +381,12 @@ impl<'a> Parser<'a> {
span = span.merge(next.pos);
self.toks.peek_forward(1);
}
if matches!(self.toks.peek(), Some(Token { kind: ' ', .. }) | Some(Token { kind: '\n', .. }) | Some(Token { kind: '\t', .. }))
{
if matches!(
self.toks.peek(),
Some(Token { kind: ' ', .. })
| Some(Token { kind: '\n', .. })
| Some(Token { kind: '\t', .. })
) {
self.toks.peek_forward(1);
}
} else {

View File

@ -115,7 +115,12 @@ impl<'a> Parser<'a> {
let value = self.parse_value(true, &|toks| {
if matches!(toks.peek(), Some(Token { kind: '!', .. })) {
let is_important = matches!(toks.peek_next(), Some(Token { kind: 'i', .. }) | Some(Token { kind: 'I', .. }) | Some(Token { kind: '=', .. }));
let is_important = matches!(
toks.peek_next(),
Some(Token { kind: 'i', .. })
| Some(Token { kind: 'I', .. })
| Some(Token { kind: '=', .. })
);
toks.reset_cursor();
!is_important
} else {

View File

@ -761,5 +761,12 @@ fn must_unify(
/// Returns whether a `CompoundSelector` may contain only one simple selector of
/// the same type as `simple`.
fn is_unique(simple: &SimpleSelector) -> bool {
matches!(simple, SimpleSelector::Id(..) | SimpleSelector::Pseudo(Pseudo { is_class: false, .. }))
matches!(
simple,
SimpleSelector::Id(..)
| SimpleSelector::Pseudo(Pseudo {
is_class: false,
..
})
)
}