mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-04 02:34:11 +02:00
clippy
This commit is contained in:
parent
da91e0592d
commit
5e034d7bef
2 changed files with 6 additions and 17 deletions
|
|
@ -33,23 +33,12 @@ pub trait Parser {
|
|||
|
||||
trait ElementExt<'a> {
|
||||
fn first_text(&self) -> Option<&'a str>;
|
||||
fn nth_text(&self, n: usize) -> Option<&'a str>;
|
||||
fn last_text(&self) -> Option<&'a str>;
|
||||
}
|
||||
|
||||
impl<'a> ElementExt<'a> for ElementRef<'a> {
|
||||
fn first_text(&self) -> Option<&'a str> {
|
||||
self.text().map(str::trim).find(|s| !s.is_empty())
|
||||
}
|
||||
fn nth_text(&self, n: usize) -> Option<&'a str> {
|
||||
self.text()
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.nth(n - 1)
|
||||
.map(str::trim)
|
||||
}
|
||||
fn last_text(&self) -> Option<&'a str> {
|
||||
self.text().map(str::trim).filter(|s| !s.is_empty()).last()
|
||||
}
|
||||
}
|
||||
|
||||
fn select_text<'a>(el: ElementRef<'a>, selector: &Selector) -> Option<&'a str> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue