diff options
author | sushi-shi <47691267+sushi-shi@users.noreply.github.com> | 2022-02-25 03:56:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-24 19:56:32 -0500 |
commit | 5451fd9865f2a75d623992a072eb639ea20e688f (patch) | |
tree | fca079a571f8fe01dc72c9a05daf6efcea18e091 /src/context | |
parent | 55b401cfa35ee3ce09d2deba94f0d490ad666e9b (diff) |
Fix clippy warnings (#144)
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/app_context.rs | 15 | ||||
-rw-r--r-- | src/context/message_queue.rs | 9 | ||||
-rw-r--r-- | src/context/tab_context.rs | 10 | ||||
-rw-r--r-- | src/context/worker_context.rs | 3 |
4 files changed, 10 insertions, 27 deletions
diff --git a/src/context/app_context.rs b/src/context/app_context.rs index 37c0565..3f7975d 100644 --- a/src/context/app_context.rs +++ b/src/context/app_context.rs @@ -77,11 +77,10 @@ impl AppContext { commandline_context.history_mut().set_max_len(20); let event_tx_for_fs_notification = event_tx.clone(); - let watcher = notify::recommended_watcher(move |res| match res { - Ok(event) => { + let watcher = notify::recommended_watcher(move |res| { + if let Ok(event) = res { let _ = event_tx_for_fs_notification.send(AppEvent::Filesystem(event)); } - Err(_) => {} }) .unwrap(); let watched_paths = HashSet::with_capacity(3); @@ -164,7 +163,7 @@ impl AppContext { } } None => { - if !self.preview_area.is_none() { + if self.preview_area.is_some() { self.call_preview_removed_hook() } } @@ -184,7 +183,7 @@ impl AppContext { /// This function can be called if an external preview shall be temporarily removed, for example /// when entering the help screen. pub fn remove_external_preview(&mut self) { - if let Some(_) = &self.preview_area { + if self.preview_area.is_some() { self.call_preview_removed_hook(); self.preview_area = None; } @@ -203,10 +202,8 @@ impl AppContext { curr_tab_ref.child_list_ref(), ]; - for list in watched_lists { - if let Some(dir_list) = list { - new_paths_to_watch.insert(dir_list.file_path().to_path_buf()); - } + for list in watched_lists.iter().flatten() { + new_paths_to_watch.insert(list.file_path().to_path_buf()); } // remove paths from watcher which don't need to be watched anymore... diff --git a/src/context/message_queue.rs b/src/context/message_queue.rs index f2995c0..f90ad53 100644 --- a/src/context/message_queue.rs +++ b/src/context/message_queue.rs @@ -13,6 +13,7 @@ impl Message { } } +#[derive(Default)] pub struct MessageQueue { contents: VecDeque<Message>, } @@ -49,11 +50,3 @@ impl MessageQueue { self.contents.front() } } - -impl std::default::Default for MessageQueue { - fn default() -> Self { - Self { - contents: VecDeque::new(), - } - } -} diff --git a/src/context/tab_context.rs b/src/context/tab_context.rs index 5e51e6f..77f75a5 100644 --- a/src/context/tab_context.rs +++ b/src/context/tab_context.rs @@ -2,20 +2,12 @@ use std::slice::IterMut; use crate::tab::JoshutoTab; +#[derive(Default)] pub struct TabContext { pub index: usize, tabs: Vec<JoshutoTab>, } -impl std::default::Default for TabContext { - fn default() -> Self { - Self { - index: 0, - tabs: Vec::new(), - } - } -} - impl TabContext { pub fn new() -> Self { Self::default() diff --git a/src/context/worker_context.rs b/src/context/worker_context.rs index bc66ffe..d3d86b8 100644 --- a/src/context/worker_context.rs +++ b/src/context/worker_context.rs @@ -29,7 +29,8 @@ impl WorkerContext { // worker related pub fn push(&mut self, thread: IoWorkerThread) { self.worker_queue.push_back(thread); - self.event_tx.send(AppEvent::IoWorkerCreate); + // error is ignored + let _ = self.event_tx.send(AppEvent::IoWorkerCreate); } pub fn is_busy(&self) -> bool { self.worker.is_some() |