Skip to content

Commit 7d14577

Browse files
committed
Edition 2024
1 parent 60cd9e7 commit 7d14577

3 files changed

Lines changed: 12 additions & 17 deletions

File tree

scraper/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scraper"
33
version = "0.25.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
description = "HTML parsing and querying with CSS selectors"
77
keywords = ["html", "css", "selector", "scraping"]

scraper/src/element_ref/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a> ElementRef<'a> {
9797
/// let children = fragment.root_element().child_elements().map(|element| element.value().name()).collect::<Vec<_>>();
9898
/// assert_eq!(children, ["span", "a"]);
9999
/// ```
100-
pub fn child_elements(&self) -> impl Iterator<Item = ElementRef<'a>> {
100+
pub fn child_elements(&self) -> impl Iterator<Item = ElementRef<'a>> + use<'a> {
101101
self.children().filter_map(ElementRef::wrap)
102102
}
103103

@@ -112,7 +112,7 @@ impl<'a> ElementRef<'a> {
112112
/// let descendants = fragment.root_element().descendent_elements().map(|element| element.value().name()).collect::<Vec<_>>();
113113
/// assert_eq!(descendants, ["html", "span", "b", "a", "i"]);
114114
/// ```
115-
pub fn descendent_elements(&self) -> impl Iterator<Item = ElementRef<'a>> {
115+
pub fn descendent_elements(&self) -> impl Iterator<Item = ElementRef<'a>> + use<'a> {
116116
self.descendants().filter_map(ElementRef::wrap)
117117
}
118118
}
@@ -165,17 +165,15 @@ impl<'a> Iterator for Select<'a, '_> {
165165

166166
fn next(&mut self) -> Option<ElementRef<'a>> {
167167
for edge in &mut self.inner {
168-
if let Edge::Open(node) = edge {
169-
if let Some(element) = ElementRef::wrap(node) {
170-
if self.selector.matches_with_scope_and_cache(
168+
if let Edge::Open(node) = edge
169+
&& let Some(element) = ElementRef::wrap(node)
170+
&& self.selector.matches_with_scope_and_cache(
171171
&element,
172172
Some(self.scope),
173173
&mut self.caches,
174174
) {
175175
return Some(element);
176176
}
177-
}
178-
}
179177
}
180178
None
181179
}
@@ -194,11 +192,10 @@ impl<'a> Iterator for Text<'a> {
194192

195193
fn next(&mut self) -> Option<&'a str> {
196194
for edge in &mut self.inner {
197-
if let Edge::Open(node) = edge {
198-
if let Node::Text(ref text) = node.value() {
195+
if let Edge::Open(node) = edge
196+
&& let Node::Text(text) = node.value() {
199197
return Some(&**text);
200198
}
201-
}
202199
}
203200
None
204201
}

scraper/src/html/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,14 @@ impl<'a> Iterator for Select<'a, '_> {
159159

160160
fn next(&mut self) -> Option<ElementRef<'a>> {
161161
for node in self.inner.by_ref() {
162-
if let Some(element) = ElementRef::wrap(node) {
163-
if element.parent().is_some()
162+
if let Some(element) = ElementRef::wrap(node)
163+
&& element.parent().is_some()
164164
&& self
165165
.selector
166166
.matches_with_scope_and_cache(&element, None, &mut self.caches)
167167
{
168168
return Some(element);
169169
}
170-
}
171170
}
172171
None
173172
}
@@ -182,15 +181,14 @@ impl<'a> Iterator for Select<'a, '_> {
182181
impl DoubleEndedIterator for Select<'_, '_> {
183182
fn next_back(&mut self) -> Option<Self::Item> {
184183
for node in self.inner.by_ref().rev() {
185-
if let Some(element) = ElementRef::wrap(node) {
186-
if element.parent().is_some()
184+
if let Some(element) = ElementRef::wrap(node)
185+
&& element.parent().is_some()
187186
&& self
188187
.selector
189188
.matches_with_scope_and_cache(&element, None, &mut self.caches)
190189
{
191190
return Some(element);
192191
}
193-
}
194192
}
195193
None
196194
}

0 commit comments

Comments
 (0)