Skip to content

Commit

Permalink
Merge pull request #220 from rust-scraper/make-clippy-happy
Browse files Browse the repository at this point in the history
Make current nightly version of Clippy happy.
  • Loading branch information
cfvescovo authored Dec 2, 2024
2 parents 93afdd9 + 47cc9de commit 8d3e74b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions scraper/src/element_ref/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::ElementRef;
use crate::selector::{CssLocalName, CssString, NonTSPseudoClass, PseudoElement, Simple};

/// Note: will never match against non-tree-structure pseudo-classes.
impl<'a> Element for ElementRef<'a> {
impl Element for ElementRef<'_> {
type Impl = Simple;

fn opaque(&self) -> OpaqueElement {
Expand Down Expand Up @@ -135,7 +135,7 @@ impl<'a> Element for ElementRef<'a> {

fn is_root(&self) -> bool {
self.parent()
.map_or(false, |parent| parent.value().is_document())
.is_some_and(|parent| parent.value().is_document())
}

fn apply_selector_flags(&self, _flags: matching::ElementSelectorFlags) {}
Expand Down
4 changes: 2 additions & 2 deletions scraper/src/element_ref/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a> ElementRef<'a> {
}
}

impl<'a> Debug for ElementRef<'a> {
impl Debug for ElementRef<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Debug::fmt(self.value(), f)
}
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Clone for Select<'_, '_> {
}
}

impl<'a, 'b> Iterator for Select<'a, 'b> {
impl<'a> Iterator for Select<'a, '_> {
type Item = ElementRef<'a>;

fn next(&mut self) -> Option<ElementRef<'a>> {
Expand Down
2 changes: 1 addition & 1 deletion scraper/src/element_ref/serializable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use html5ever::serialize::{Serialize, Serializer, TraversalScope};

use crate::ElementRef;

impl<'a> Serialize for ElementRef<'a> {
impl Serialize for ElementRef<'_> {
fn serialize<S: Serializer>(
&self,
serializer: &mut S,
Expand Down
4 changes: 2 additions & 2 deletions scraper/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<'a> From<SelectorParseErrorKind<'a>> for SelectorErrorKind<'a> {
}
}

impl<'a> Display for SelectorErrorKind<'a> {
impl Display for SelectorErrorKind<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<'a> Display for SelectorErrorKind<'a> {
}
}

impl<'a> Error for SelectorErrorKind<'a> {
impl Error for SelectorErrorKind<'_> {
fn description(&self) -> &str {
match self {
Self::UnexpectedToken(_) => "Token was not expected",
Expand Down
4 changes: 2 additions & 2 deletions scraper/src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Clone for Select<'_, '_> {
}
}

impl<'a, 'b> Iterator for Select<'a, 'b> {
impl<'a> Iterator for Select<'a, '_> {
type Item = ElementRef<'a>;

fn next(&mut self) -> Option<ElementRef<'a>> {
Expand All @@ -178,7 +178,7 @@ impl<'a, 'b> Iterator for Select<'a, 'b> {
}
}

impl<'a, 'b> DoubleEndedIterator for Select<'a, 'b> {
impl DoubleEndedIterator for Select<'_, '_> {
fn next_back(&mut self) -> Option<Self::Item> {
for node in self.inner.by_ref().rev() {
if let Some(element) = ElementRef::wrap(node) {
Expand Down
19 changes: 8 additions & 11 deletions scraper/src/html/tree_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TreeSink for HtmlTreeSink {
NodeOrText::AppendText(text) => {
let text = make_tendril(text);

let did_concat = parent.last_child().map_or(false, |mut n| match n.value() {
let did_concat = parent.last_child().is_some_and(|mut n| match n.value() {
Node::Text(t) => {
t.text.push_tendril(&text);
true
Expand Down Expand Up @@ -181,16 +181,13 @@ impl TreeSink for HtmlTreeSink {
NodeOrText::AppendText(text) => {
let text = make_tendril(text);

let did_concat =
sibling
.prev_sibling()
.map_or(false, |mut n| match n.value() {
Node::Text(t) => {
t.text.push_tendril(&text);
true
}
_ => false,
});
let did_concat = sibling.prev_sibling().is_some_and(|mut n| match n.value() {
Node::Text(t) => {
t.text.push_tendril(&text);
true
}
_ => false,
});

if !did_concat {
sibling.insert_before(Node::Text(Text { text }));
Expand Down
3 changes: 1 addition & 2 deletions scraper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ fn main() {
.iter()
.map(File::open)
.map(Result::unwrap)
.map(|mut f| query(&input, &output, &selector, &mut f))
.any(|m| m)
.any(|mut f| query(&input, &output, &selector, &mut f))
};

process::exit(i32::from(!matched));
Expand Down

0 comments on commit 8d3e74b

Please sign in to comment.