From b640970819482aa61eb5a7a661644e8f41a5aed6 Mon Sep 17 00:00:00 2001 From: Matthias Sieber Date: Wed, 1 Aug 2018 16:40:43 -0700 Subject: changes as suggested by clippy --- src/content.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/content.rs') diff --git a/src/content.rs b/src/content.rs index 8b48411..0f81149 100644 --- a/src/content.rs +++ b/src/content.rs @@ -54,14 +54,14 @@ pub fn get_extract(v: &Value) -> Result { // format to plain text let extract = extract.replace("\\\\", "\\"); - Ok(format!("{}", extract)) + Ok(extract.to_string()) } // ignore non strings - _ => Ok(format!("This page does not exist anymore")), + _ => Ok("This page does not exist anymore".to_string()), } } -pub fn extract_formatter(extract: String) -> StyledString { +pub fn extract_formatter(extract: &str) -> StyledString { let mut formatted = StyledString::new(); let heading = Regex::new(r"^== (?P.*) ==$").unwrap(); @@ -103,10 +103,8 @@ pub fn get_search_results(search: &str) -> Result, reqwest::Error> { let mut results: Vec = vec![]; for item in v[1].as_array().unwrap() { - match item { - Value::String(x) => results.push(x.to_string()), - // ignore non strings - _ => (), + if let Value::String(x) = item { + results.push(x.to_string()) } } Ok(results) @@ -135,21 +133,21 @@ pub fn get_links(v: &Value) -> Result, reqwest::Error> { Ok(links) } -pub fn pop_error(s: &mut Cursive, msg: String) { - s.add_layer(Dialog::text(format!("{}", msg)).button("Ok", |s| s.quit())); +pub fn pop_error(s: &mut Cursive, msg: &str) { + s.add_layer(Dialog::text(msg.to_string()).button("Ok", |s| s.quit())); } -pub fn handler(e: reqwest::Error) -> String { +pub fn handler(e: &reqwest::Error) -> String { let mut msg: String = String::new(); if e.is_http() { match e.url() { - None => msg.push_str(&format!("No URL given")), + None => msg.push_str(&"No URL given"), Some(url) => msg.push_str(&format!("Problem making request to: {}", url)), } } if e.is_redirect() { - msg.push_str(&format!("server redirecting too many times or making loop")); + msg.push_str(&"server redirecting too many times or making loop"); } msg -- cgit v1.2.3