From b73448b189435ed80c0f198261da93d235d9cab9 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Wed, 6 Jan 2021 10:32:43 +0100 Subject: [PATCH] fix clippy lints --- src/config/mod.rs | 2 +- src/lib.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index b7d6e6a..9323b6c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -191,7 +191,7 @@ impl GrabberConfig { } } - fn split_values<'a>(values: &'a str) -> Vec<&'a str> { + fn split_values(values: &str) -> Vec<&str> { values.split('|').map(|s| s.trim()).collect() } } diff --git a/src/lib.rs b/src/lib.rs index e587895..928d472 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -508,10 +508,7 @@ impl ArticleScraper { tag: Option<&str>, attribute: &str, ) -> Result<(), ScraperError> { - let xpath_tag = match tag { - Some(tag) => tag, - None => "*", - }; + let xpath_tag = tag.unwrap_or("*"); let xpath = &format!("//{}[@{}]", xpath_tag, attribute); let node_vec = Self::evaluate_xpath(context, xpath, false)?; @@ -529,10 +526,7 @@ impl ArticleScraper { attribute: &str, value: &str, ) -> Result<(), ScraperError> { - let xpath_tag = match tag { - Some(tag) => tag, - None => "*", - }; + let xpath_tag = tag.unwrap_or("*"); let xpath = &format!("//{}", xpath_tag); let node_vec = Self::evaluate_xpath(context, xpath, false)?; @@ -598,7 +592,7 @@ impl ArticleScraper { } if !completed_url.ends_with('/') && !incomplete_url.starts_with('/') { - completed_url.push_str("/"); + completed_url.push('/'); } completed_url.push_str(incomplete_url); let url = url::Url::parse(&completed_url).context(ScraperErrorKind::Url)?;