diff --git a/src/lib.rs b/src/lib.rs index 1cfb1c9..57c1b18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -337,7 +337,7 @@ impl<'a> StyleSheetParser<'a> { | TokenKind::Symbol(Symbol::Mul) | TokenKind::Symbol(Symbol::Percent) | 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(_) => { self.lexer.next(); continue; @@ -382,7 +382,7 @@ impl<'a> StyleSheetParser<'a> { TokenKind::AtRule(AtRuleKind::Include) => rules.extend(eat_include( &mut self.lexer, &self.global_scope, - &Selector(Vec::new()), + &Selector::new(), )?), TokenKind::AtRule(AtRuleKind::Import) => { let Token { pos, .. } = self diff --git a/src/selector.rs b/src/selector.rs index 68de4b8..a2eb235 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -12,6 +12,12 @@ use std::vec::IntoIter; #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct Selector(pub Vec); +impl Selector { + pub fn new() -> Selector { + Selector(Vec::new()) + } +} + impl Display for Selector { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut iter = self.0.iter().peekable();