summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tay <samctay@pm.me>2022-02-22 15:24:23 -0500
committerSam Tay <samctay@pm.me>2022-02-22 15:24:23 -0500
commitb32e23caf1e858778e26c396063ef2ef1192e4c1 (patch)
tree2fe32034d1f832e20de14b878d3363bb7627a599
parent6c7c2b109613f7125a8e6aaa5220d85e89c04944 (diff)
Obey clippy
-rw-r--r--src/error.rs4
-rw-r--r--src/stackexchange/api.rs2
-rw-r--r--src/stackexchange/scraper.rs6
-rw-r--r--src/tui/app.rs4
4 files changed, 7 insertions, 9 deletions
diff --git a/src/error.rs b/src/error.rs
index 05ba004..2bcb899 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -15,7 +15,7 @@ pub enum Error {
#[error("SerdeYaml error: {0}")]
SerdeYaml(#[from] serde_yaml::Error),
#[error("Futures Join error : {0}")]
- JoinError(#[from] tokio::task::JoinError),
+ Join(#[from] tokio::task::JoinError),
#[error("File `{}` is malformed; try removing it", .0.display())]
MalformedFile(PathBuf),
#[error("Lacking {0:?} permissions on `{}`", .1.display())]
@@ -23,7 +23,7 @@ pub enum Error {
#[error("{0}")]
StackExchange(String),
#[error("{0}")]
- ScrapingError(String),
+ Scraping(String),
#[error("Couldn't find a suitable project directory; is your OS supported?")]
ProjectDir,
#[error("Sorry, couldn't find any answers to your question")]
diff --git a/src/stackexchange/api.rs b/src/stackexchange/api.rs
index c9b69b4..cf326f2 100644
--- a/src/stackexchange/api.rs
+++ b/src/stackexchange/api.rs
@@ -153,7 +153,7 @@ impl Api {
params.insert("filter", SE_FILTER);
params.insert("page", "1");
if let Some(key) = &self.api_key {
- params.insert("key", &key);
+ params.insert("key", key);
}
params
}
diff --git a/src/stackexchange/scraper.rs b/src/stackexchange/scraper.rs
index 97c4bef..b1354fa 100644
--- a/src/stackexchange/scraper.rs
+++ b/src/stackexchange/scraper.rs
@@ -51,7 +51,7 @@ impl Scraper for DuckDuckGo {
parse_with_selector(anchors, html, sites, limit).and_then(|sd| {
// DDG seems to never have empty results, so assume this is blocked
if sd.question_ids.is_empty() {
- Err(Error::ScrapingError(String::from(
+ Err(Error::Scraping(String::from(
"DuckDuckGo blocked this request",
)))
} else {
@@ -325,9 +325,7 @@ mod tests {
);
match DuckDuckGo.parse(html, &sites, 2) {
- Err(Error::ScrapingError(s)) if s == "DuckDuckGo blocked this request".to_string() => {
- Ok(())
- }
+ Err(Error::Scraping(s)) if s == "DuckDuckGo blocked this request".to_string() => Ok(()),
_ => Err(String::from("Failed to detect DuckDuckGo blocker")),
}
}
diff --git a/src/tui/app.rs b/src/tui/app.rs
index bdd4665..7160cce 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -85,7 +85,7 @@ pub fn run(qs: Vec<Question<Markdown>>) -> Result<()> {
fn question_selected_callback(
question_map: Arc<HashMap<u32, Question<Markdown>>>,
- mut s: &mut Cursive,
+ s: &mut Cursive,
qid: u32,
) {
let q = question_map.get(&qid).unwrap();
@@ -102,7 +102,7 @@ fn question_selected_callback(
v.reset_with_all(q.answers.iter().map(|a| (preview_answer(x, a), a.id)))
})
.expect("Panic: setting answer list content failed");
- cb(&mut s)
+ cb(s)
}
fn preview_question(q: &Question<Markdown>) -> StyledString {