mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-07 08:05:31 +02:00
clippy
This commit is contained in:
parent
b13673ce3b
commit
a1ee3b22f9
1 changed files with 6 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::fmt::Write;
|
||||||
use libxml::{
|
use libxml::{
|
||||||
tree::{Document, Node, NodeType, SaveOptions},
|
tree::{Document, Node, NodeType, SaveOptions},
|
||||||
xpath::Context,
|
xpath::Context,
|
||||||
|
@ -190,7 +190,7 @@ impl Util {
|
||||||
|
|
||||||
pub fn extract_value(context: &Context, xpath: &str) -> Result<String, FullTextParserError> {
|
pub fn extract_value(context: &Context, xpath: &str) -> Result<String, FullTextParserError> {
|
||||||
let node_vec = Util::evaluate_xpath(context, xpath, false)?;
|
let node_vec = Util::evaluate_xpath(context, xpath, false)?;
|
||||||
if let Some(val) = node_vec.get(0) {
|
if let Some(val) = node_vec.first() {
|
||||||
return Ok(val.get_content());
|
return Ok(val.get_content());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +207,10 @@ impl Util {
|
||||||
let part = node
|
let part = node
|
||||||
.get_content()
|
.get_content()
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.map(|s| format!("{} ", s))
|
.fold(String::new(), |mut output, s| {
|
||||||
.collect::<String>();
|
let _ = write!(output, " {s}");
|
||||||
|
output
|
||||||
|
});
|
||||||
val.push_str(&part);
|
val.push_str(&part);
|
||||||
val.push(' ');
|
val.push(' ');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue