From 362a9b4ca24739d95efdc5ac89480e483bb209b4 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 5 Jan 2020 20:55:58 -0500 Subject: [PATCH] Move around clones on selectors --- src/selector.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/selector.rs b/src/selector.rs index e57481f..ce40b71 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -137,26 +137,24 @@ impl<'a> SelectorParser<'a> { fn consume_selector(&mut self) -> Option { if let Some(tok) = self.tokens.next() { - let selector = match tok.kind { + let selector = match &tok.kind { TokenKind::Symbol(Symbol::Period) => match self .tokens .next() .expect("expected ident after `.`") - .clone() .kind { - TokenKind::Ident(tok) => Selector::Class(tok), + TokenKind::Ident(ref tok) => Selector::Class(tok.clone()), _ => todo!("there should normally be an ident after `.`"), }, TokenKind::Symbol(Symbol::Mul) => Selector::Universal, - TokenKind::Symbol(Symbol::Hash) => match self + TokenKind::Symbol(Symbol::Hash) => match &self .tokens .next() .expect("expected ident after `#`") - .clone() .kind { - TokenKind::Ident(tok) => Selector::Id(tok), + TokenKind::Ident(ref tok) => Selector::Id(tok.clone()), _ => todo!("there should normally be an ident after `#`"), }, TokenKind::Symbol(Symbol::Colon) => { @@ -164,15 +162,14 @@ impl<'a> SelectorParser<'a> { .tokens .next() .expect("expected ident after `:`") - .clone() .kind { - TokenKind::Ident(tok) => Selector::Pseudo(tok), + TokenKind::Ident(ref tok) => Selector::Pseudo(tok.clone()), _ => todo!("there should normally be an ident after `:`"), } } - TokenKind::Ident(ref tok) => Selector::Element(tok.clone()), - TokenKind::Selector(ref sel) => sel.clone(), + TokenKind::Ident(tok) => Selector::Element(tok.clone()), + TokenKind::Selector(sel) => sel.clone(), _ => todo!(), }; Some(selector)