Skip to content

Commit

Permalink
Merge pull request #10 from brave/clippy
Browse files Browse the repository at this point in the history
clippy: Use Iterator::find
  • Loading branch information
antonok-edm authored May 3, 2023
2 parents 78136d1 + 4a14e45 commit 0a5973e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,10 @@ where

#[inline]
fn next(&mut self) -> Option<NodeDataRef<ElementData>> {
for element in self.iter.by_ref() {
if self.selectors.borrow().matches(&element) {
return Some(element);
}
}
None
let selectors = self.selectors.borrow();
self.iter
.by_ref()
.find(|element| selectors.matches(element))
}
}

Expand All @@ -415,12 +413,11 @@ where
{
#[inline]
fn next_back(&mut self) -> Option<NodeDataRef<ElementData>> {
for element in self.iter.by_ref().rev() {
if self.selectors.borrow().matches(&element) {
return Some(element);
}
}
None
let selectors = self.selectors.borrow();
self.iter
.by_ref()
.rev()
.find(|element| selectors.matches(element))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn parse_and_serialize_fragment() {
#[test]
fn parse_file() {
let mut path = Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf();
path.push("test_data".to_string());
path.push("test_data");
path.push("foo.html");

let html = r"<!DOCTYPE html><html><head>
Expand Down

0 comments on commit 0a5973e

Please sign in to comment.