Implement Selector::new() utility function
This commit is contained in:
parent
2c38db8703
commit
cacf8c41ab
@ -337,7 +337,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
| TokenKind::Symbol(Symbol::Mul)
|
| TokenKind::Symbol(Symbol::Mul)
|
||||||
| TokenKind::Symbol(Symbol::Percent)
|
| TokenKind::Symbol(Symbol::Percent)
|
||||||
| TokenKind::Symbol(Symbol::Period) => rules
|
| TokenKind::Symbol(Symbol::Period) => rules
|
||||||
.extend(self.eat_rules(&Selector(Vec::new()), &mut self.global_scope.clone())?),
|
.extend(self.eat_rules(&Selector::new(), &mut self.global_scope.clone())?),
|
||||||
TokenKind::Whitespace(_) => {
|
TokenKind::Whitespace(_) => {
|
||||||
self.lexer.next();
|
self.lexer.next();
|
||||||
continue;
|
continue;
|
||||||
@ -382,7 +382,7 @@ impl<'a> StyleSheetParser<'a> {
|
|||||||
TokenKind::AtRule(AtRuleKind::Include) => rules.extend(eat_include(
|
TokenKind::AtRule(AtRuleKind::Include) => rules.extend(eat_include(
|
||||||
&mut self.lexer,
|
&mut self.lexer,
|
||||||
&self.global_scope,
|
&self.global_scope,
|
||||||
&Selector(Vec::new()),
|
&Selector::new(),
|
||||||
)?),
|
)?),
|
||||||
TokenKind::AtRule(AtRuleKind::Import) => {
|
TokenKind::AtRule(AtRuleKind::Import) => {
|
||||||
let Token { pos, .. } = self
|
let Token { pos, .. } = self
|
||||||
|
@ -12,6 +12,12 @@ use std::vec::IntoIter;
|
|||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub(crate) struct Selector(pub Vec<SelectorKind>);
|
pub(crate) struct Selector(pub Vec<SelectorKind>);
|
||||||
|
|
||||||
|
impl Selector {
|
||||||
|
pub fn new() -> Selector {
|
||||||
|
Selector(Vec::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Display for Selector {
|
impl Display for Selector {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let mut iter = self.0.iter().peekable();
|
let mut iter = self.0.iter().peekable();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user