Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 37ddffe

Browse files
authoredJul 20, 2021··
Fix all the Clippy warnings
1 parent 6b51ced commit 37ddffe

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed
 

‎src/lib.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ impl fmt::Display for StyleSheet<'_> {
242242
}
243243
}
244244

245+
impl<'a> Default for StyleSheet<'a> {
246+
fn default() -> Self {
247+
Self::new()
248+
}
249+
}
250+
245251
fn consume_statement<'a>(s: &mut Stream<'a>, rules: &mut Vec<Rule<'a>>) -> Result<(), Error> {
246252
if s.curr_byte() == Ok(b'@') {
247253
s.advance(1);
@@ -295,8 +301,8 @@ fn consume_rule_set<'a>(s: &mut Stream<'a>, rules: &mut Vec<Rule<'a>>) -> Result
295301
s.try_consume_byte(b'{');
296302

297303
let declarations = consume_declarations(s)?;
298-
for i in start_rule_idx..rules.len() {
299-
rules[i].declarations = declarations.clone();
304+
for rule in rules.iter_mut().skip(start_rule_idx) {
305+
rule.declarations = declarations.clone();
300306
}
301307

302308
s.try_consume_byte(b'}');
@@ -454,11 +460,8 @@ fn consume_declaration<'a>(s: &mut Stream<'a>) -> Result<Declaration<'a>, Error>
454460

455461
fn consume_term(s: &mut Stream) -> Result<(), Error> {
456462
fn consume_digits(s: &mut Stream) {
457-
while let Ok(c) = s.curr_byte() {
458-
match c {
459-
b'0'..=b'9' => s.advance(1),
460-
_ => break,
461-
}
463+
while let Ok(b'0'..=b'9') = s.curr_byte() {
464+
s.advance(1);
462465
}
463466
}
464467

‎src/selector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'a> Selector<'a> {
180180
}
181181

182182
fn matches_impl<E: Element>(&self, idx: usize, element: &E) -> bool {
183-
let ref component = self.components[idx];
183+
let component = &self.components[idx];
184184

185185
if !match_selector(&component.selector, element) {
186186
return false;

‎src/stream.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) struct Stream<'a> {
4949

5050
impl<'a> From<&'a str> for Stream<'a> {
5151
fn from(text: &'a str) -> Self {
52-
Stream::new(text.into()).into()
52+
Stream::new(text)
5353
}
5454
}
5555

@@ -283,7 +283,7 @@ impl<'a> Stream<'a> {
283283

284284
#[inline(never)]
285285
pub fn gen_text_pos_from(&self, pos: usize) -> TextPos {
286-
let mut s = self.clone();
286+
let mut s = *self;
287287
s.pos = std::cmp::min(pos, self.text.len());
288288
s.gen_text_pos()
289289
}

0 commit comments

Comments
 (0)
Please sign in to comment.