aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2018-07-22 03:12:08 +0100
committerGitHub <[email protected]>2018-07-22 03:12:08 +0100
commit0ad9e725683eda9a76b5ba75bbc9a4f4bf7ab29b (patch)
treed7db983d5516f167719a59f79ac130d9dd3f3ddf /src
parent650f6fb3656d4c302dadedd4c1876f7d3b5e21db (diff)
parent45aa4748b0b19efd5f84d32e7ae6f66643275490 (diff)
Merge pull request #3 from gyscos/replace
Fix usage of str::replace
Diffstat (limited to 'src')
-rw-r--r--src/content.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/content.rs b/src/content.rs
index 7ebc129..8d025c9 100644
--- a/src/content.rs
+++ b/src/content.rs
@@ -30,13 +30,13 @@ pub fn query_url_gen(title: &str) -> String {
30 30
31pub fn search_url_gen(search: &str) -> String { 31pub fn search_url_gen(search: &str) -> String {
32 // search config 32 // search config
33 search.replace(" ", "%20"); 33 let search = search.replace(" ", "%20");
34 let mut url = String::from("https://en.wikipedia.org"); 34 let mut url = String::from("https://en.wikipedia.org");
35 url.push_str("/w/api.php?"); 35 url.push_str("/w/api.php?");
36 url.push_str("action=opensearch&"); 36 url.push_str("action=opensearch&");
37 url.push_str("format=json&"); 37 url.push_str("format=json&");
38 url.push_str("search="); 38 url.push_str("search=");
39 url.push_str(&urlencoding::encode(search)); 39 url.push_str(&urlencoding::encode(&search));
40 url.push_str("&"); 40 url.push_str("&");
41 url.push_str("limit=20"); 41 url.push_str("limit=20");
42 url 42 url
@@ -52,7 +52,7 @@ pub fn get_extract(v: &Value) -> Result<String, reqwest::Error> {
52 match &v["query"]["pages"][pageid_str]["extract"] { 52 match &v["query"]["pages"][pageid_str]["extract"] {
53 Value::String(extract) => { 53 Value::String(extract) => {
54 // format to plain text 54 // format to plain text
55 extract.replace("\\\\", "\\"); 55 let extract = extract.replace("\\\\", "\\");
56 56
57 Ok(format!("{}", extract)) 57 Ok(format!("{}", extract))
58 } 58 }