From a1ee3b22f98943bac5bfd8e1801c4c9bc6066d43 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Tue, 13 Feb 2024 19:35:29 +0100 Subject: [PATCH] clippy --- article_scraper/src/util.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/article_scraper/src/util.rs b/article_scraper/src/util.rs index 874e696..1aba153 100644 --- a/article_scraper/src/util.rs +++ b/article_scraper/src/util.rs @@ -1,5 +1,5 @@ use std::collections::HashSet; - +use std::fmt::Write; use libxml::{ tree::{Document, Node, NodeType, SaveOptions}, xpath::Context, @@ -190,7 +190,7 @@ impl Util { pub fn extract_value(context: &Context, xpath: &str) -> Result { 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()); } @@ -207,8 +207,10 @@ impl Util { let part = node .get_content() .split_whitespace() - .map(|s| format!("{} ", s)) - .collect::(); + .fold(String::new(), |mut output, s| { + let _ = write!(output, " {s}"); + output + }); val.push_str(&part); val.push(' '); }