summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-24 01:38:15 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-24 01:38:15 -0700
commitcaa03bb164e40827e0d5f3f35522ac3cabc1e348 (patch)
tree99ec9045cba473d4d57888c593938196d0eeab6f /src
parent9d1e601554a982c2932e2161b153104d4cc14424 (diff)
Dont make unnecessary Client
This client is now only being used in one place, so just make it there if necesssary
Diffstat (limited to 'src')
-rw-r--r--src/stackexchange/search.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/stackexchange/search.rs b/src/stackexchange/search.rs
index 945c66e..8e40cb4 100644
--- a/src/stackexchange/search.rs
+++ b/src/stackexchange/search.rs
@@ -26,7 +26,6 @@ const USER_AGENT: &str =
#[derive(Clone)]
pub struct Search {
api: Api,
- client: Client,
config: Config,
query: String,
sites: HashMap<String, String>,
@@ -34,12 +33,10 @@ pub struct Search {
impl Search {
pub fn new(config: Config, local_storage: LocalStorage, query: String) -> Self {
- let client = Client::new();
let api = Api::new(config.api_key.clone());
let sites = local_storage.get_urls(&config.sites);
Search {
api,
- client,
config,
query,
sites,
@@ -94,8 +91,7 @@ impl Search {
/// Search query at duckduckgo and then fetch the resulting questions from SE.
async fn search_by_engine(&self, search_engine: SearchEngine) -> Result<Vec<Question<String>>> {
let url = search_engine.get_url(&self.query, self.sites.values());
- let html = self
- .client
+ let html = Client::new()
.get(url)
.header(header::USER_AGENT, USER_AGENT)
.send()