From cacf8c41ab6417b5ada4b9323edb68c0cb88f6cf Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 22 Feb 2020 10:25:30 -0500 Subject: [PATCH] Implement Selector::new() utility function --- src/lib.rs | 4 ++-- src/selector.rs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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();