diff options
author | Akshay <[email protected]> | 2018-08-02 17:31:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2018-08-02 17:31:14 +0100 |
commit | 4b49ddfab6a5a957d651795bedd9f26dfc0a4635 (patch) | |
tree | a4db950741a2aa99881e55e38bee4e57121292e6 /src/content.rs | |
parent | cb93bc02b13432ccfe5e231ebde1edd033a2b388 (diff) | |
parent | b640970819482aa61eb5a7a661644e8f41a5aed6 (diff) |
Merge pull request #11 from manonthemat/master
changes as suggested by clippy
Diffstat (limited to 'src/content.rs')
-rw-r--r-- | src/content.rs | 22 |
1 files changed, 10 insertions, 12 deletions
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<String, reqwest::Error> { | |||
54 | // format to plain text | 54 | // format to plain text |
55 | let extract = extract.replace("\\\\", "\\"); | 55 | let extract = extract.replace("\\\\", "\\"); |
56 | 56 | ||
57 | Ok(format!("{}", extract)) | 57 | Ok(extract.to_string()) |
58 | } | 58 | } |
59 | // ignore non strings | 59 | // ignore non strings |
60 | _ => Ok(format!("This page does not exist anymore")), | 60 | _ => Ok("This page does not exist anymore".to_string()), |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | pub fn extract_formatter(extract: String) -> StyledString { | 64 | pub fn extract_formatter(extract: &str) -> StyledString { |
65 | let mut formatted = StyledString::new(); | 65 | let mut formatted = StyledString::new(); |
66 | 66 | ||
67 | let heading = Regex::new(r"^== (?P<d>.*) ==$").unwrap(); | 67 | let heading = Regex::new(r"^== (?P<d>.*) ==$").unwrap(); |
@@ -103,10 +103,8 @@ pub fn get_search_results(search: &str) -> Result<Vec<String>, reqwest::Error> { | |||
103 | 103 | ||
104 | let mut results: Vec<String> = vec![]; | 104 | let mut results: Vec<String> = vec![]; |
105 | for item in v[1].as_array().unwrap() { | 105 | for item in v[1].as_array().unwrap() { |
106 | match item { | 106 | if let Value::String(x) = item { |
107 | Value::String(x) => results.push(x.to_string()), | 107 | results.push(x.to_string()) |
108 | // ignore non strings | ||
109 | _ => (), | ||
110 | } | 108 | } |
111 | } | 109 | } |
112 | Ok(results) | 110 | Ok(results) |
@@ -135,21 +133,21 @@ pub fn get_links(v: &Value) -> Result<Vec<String>, reqwest::Error> { | |||
135 | Ok(links) | 133 | Ok(links) |
136 | } | 134 | } |
137 | 135 | ||
138 | pub fn pop_error(s: &mut Cursive, msg: String) { | 136 | pub fn pop_error(s: &mut Cursive, msg: &str) { |
139 | s.add_layer(Dialog::text(format!("{}", msg)).button("Ok", |s| s.quit())); | 137 | s.add_layer(Dialog::text(msg.to_string()).button("Ok", |s| s.quit())); |
140 | } | 138 | } |
141 | 139 | ||
142 | pub fn handler(e: reqwest::Error) -> String { | 140 | pub fn handler(e: &reqwest::Error) -> String { |
143 | let mut msg: String = String::new(); | 141 | let mut msg: String = String::new(); |
144 | if e.is_http() { | 142 | if e.is_http() { |
145 | match e.url() { | 143 | match e.url() { |
146 | None => msg.push_str(&format!("No URL given")), | 144 | None => msg.push_str(&"No URL given"), |
147 | Some(url) => msg.push_str(&format!("Problem making request to: {}", url)), | 145 | Some(url) => msg.push_str(&format!("Problem making request to: {}", url)), |
148 | } | 146 | } |
149 | } | 147 | } |
150 | 148 | ||
151 | if e.is_redirect() { | 149 | if e.is_redirect() { |
152 | msg.push_str(&format!("server redirecting too many times or making loop")); | 150 | msg.push_str(&"server redirecting too many times or making loop"); |
153 | } | 151 | } |
154 | 152 | ||
155 | msg | 153 | msg |