diff options
author | Sam Tay <sam.chong.tay@gmail.com> | 2020-06-16 18:45:31 -0700 |
---|---|---|
committer | Sam Tay <sam.chong.tay@gmail.com> | 2020-06-16 18:45:31 -0700 |
commit | c5ce14473eb2c7e1eac4b6b01fb864546280b67e (patch) | |
tree | ae2dbb0c162cc5c0b591125fcedad842ce806c81 | |
parent | a96f950af40248a5143e4b43e06e34ee878aefbf (diff) |
Clean up clippy suggestions
-rw-r--r-- | src/tui/app.rs | 8 | ||||
-rw-r--r-- | src/tui/markdown.rs | 5 | ||||
-rw-r--r-- | src/tui/views.rs | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/tui/app.rs b/src/tui/app.rs index c17cf32..bb0a923 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -1,5 +1,5 @@ use cursive::event::Event; -use cursive::theme::{BaseColor, Color, ColorStyle, Effect, Style}; +use cursive::theme::{BaseColor, Color, Effect, Style}; use cursive::utils::markup::StyledString; use cursive::utils::span::SpannedString; use cursive::Cursive; @@ -40,7 +40,7 @@ pub fn run(qs: Vec<Question>) -> Result<()> { let question_list_view = ListView::new_with_items( Name::QuestionList, qs.into_iter().map(|q| (preview_question(&q), q.id)), - move |s, qid| question_selected_callback(question_map.clone(), s, qid), + move |s, qid| question_selected_callback(question_map.clone(), s, *qid), ); let answer_list_view = ListView::new(Name::AnswerList, move |s, aid| { @@ -76,9 +76,9 @@ pub fn run(qs: Vec<Question>) -> Result<()> { fn question_selected_callback( question_map: Arc<HashMap<u32, Question>>, mut s: &mut Cursive, - qid: &u32, + qid: u32, ) { - let q = question_map.get(qid).unwrap(); + let q = question_map.get(&qid).unwrap(); let XY { x, y: _y } = s.screen_size(); // Update question view s.call_on_name(NAME_QUESTION_VIEW, |v: &mut MdView| { diff --git a/src/tui/markdown.rs b/src/tui/markdown.rs index ff1a0cb..6c44684 100644 --- a/src/tui/markdown.rs +++ b/src/tui/markdown.rs @@ -61,12 +61,11 @@ where fn preprocess(input: String) -> String { // TODO handle other stackexchange oddities here ENTITIES // TODO then benchmark - let input = input + input .as_str() .trim() .replace("<kbd>", "**[") - .replace("</kbd>", "]**"); - input + .replace("</kbd>", "]**") } /// Parse the given markdown text into a list of spans. diff --git a/src/tui/views.rs b/src/tui/views.rs index b0d0224..2fc2136 100644 --- a/src/tui/views.rs +++ b/src/tui/views.rs @@ -460,7 +460,7 @@ impl LayoutView { } } - fn call_on_list_views<F>(&mut self, f: F) -> () + fn call_on_list_views<F>(&mut self, f: F) where F: Fn(&mut ListView) + 'static, { @@ -473,7 +473,7 @@ impl LayoutView { .expect("Panic: call on answer list failed"); } - fn call_on_md_views<F>(&mut self, f: F) -> () + fn call_on_md_views<F>(&mut self, f: F) where F: Fn(&mut MdView) + 'static, { |