diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-09 11:54:47 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-15 13:21:14 +0300 |
commit | ecb3fd7f3d5bab2a6f0f7592d2f45928d90fdf56 (patch) | |
tree | 8565f9c9306a9c042b4e43bf5f804a578b86cadb /ui | |
parent | d1d11356db1b3ec261857fc33eb3073c0da097e4 (diff) |
Add dyn keyword to Trait objects
And fix some unused var warnings as well
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/contacts/contact_list.rs | 2 | ||||
-rw-r--r-- | ui/src/components/indexer/index.rs | 3 | ||||
-rw-r--r-- | ui/src/components/mail/listing/compact.rs | 6 | ||||
-rw-r--r-- | ui/src/components/mail/listing/thread.rs | 8 | ||||
-rw-r--r-- | ui/src/components/mail/view.rs | 4 | ||||
-rw-r--r-- | ui/src/components/mail/view/envelope.rs | 4 | ||||
-rw-r--r-- | ui/src/components/utilities.rs | 26 | ||||
-rw-r--r-- | ui/src/components/utilities/widgets.rs | 2 | ||||
-rw-r--r-- | ui/src/conf/accounts.rs | 4 | ||||
-rw-r--r-- | ui/src/execute/actions.rs | 2 | ||||
-rw-r--r-- | ui/src/state.rs | 6 |
11 files changed, 28 insertions, 39 deletions
diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs index 3807bc12..a718ef0f 100644 --- a/ui/src/components/contacts/contact_list.rs +++ b/ui/src/components/contacts/contact_list.rs @@ -22,7 +22,7 @@ pub struct ContactList { mode: ViewMode, dirty: bool, - view: Option<Box<Component>>, + view: Option<Box<dyn Component>>, id: ComponentId, } diff --git a/ui/src/components/indexer/index.rs b/ui/src/components/indexer/index.rs index 0472e67a..585b3703 100644 --- a/ui/src/components/indexer/index.rs +++ b/ui/src/components/indexer/index.rs @@ -33,7 +33,7 @@ pub struct Index { dirty: bool, state: IndexState, - content: Box<IndexContent>, + content: Box<dyn IndexContent>, id: ComponentId, } @@ -117,7 +117,6 @@ impl Component for Index { IndexState::Unfocused => { self.content.draw(grid, area, context); } - //IndexState::Search => unreachable!(), } self.dirty = false; diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 72a7a1fa..c557e1d7 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -112,11 +112,6 @@ impl ListingTrait for CompactListing { return; } let i = self.get_envelope_under_cursor(idx, context); - let account = &context.accounts[self.cursor_pos.0]; - let is_seen = { - let root_envelope: &Envelope = &account.get_env(&i); - root_envelope.is_seen() - }; let fg_color = self.data_columns.columns[0][(0, idx)].fg(); let bg_color = if self.cursor_pos.2 == idx { @@ -128,7 +123,6 @@ impl ListingTrait for CompactListing { }; let (upper_left, bottom_right) = area; - let (width, height) = self.data_columns.columns[3].size(); change_colors(grid, area, fg_color, bg_color); let mut x = get_x(upper_left) + self.data_columns.widths[0] diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index e9fb9d29..6a1169e2 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -502,12 +502,8 @@ impl Component for ThreadListing { false } else { let account = &mut context.accounts[self.cursor_pos.0]; - let (hash, is_seen) = { - let envelope: &Envelope = - &account.get_env(&self.locations[self.cursor_pos.2]); - (envelope.hash(), envelope.is_seen()) - }; - is_seen + let envelope: &Envelope = &account.get_env(&self.locations[self.cursor_pos.2]); + envelope.is_seen() } }; diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 0e7a24be..a8cc3d80 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -68,7 +68,7 @@ impl ViewMode { pub struct MailView { coordinates: (usize, usize, EnvelopeHash), pager: Option<Pager>, - subview: Option<Box<Component>>, + subview: Option<Box<dyn Component>>, dirty: bool, mode: ViewMode, expand_headers: bool, @@ -89,7 +89,7 @@ impl MailView { pub fn new( coordinates: (usize, usize, EnvelopeHash), pager: Option<Pager>, - subview: Option<Box<Component>>, + subview: Option<Box<dyn Component>>, ) -> Self { MailView { coordinates, diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs index 3cb4a516..58e49a6d 100644 --- a/ui/src/components/mail/view/envelope.rs +++ b/ui/src/components/mail/view/envelope.rs @@ -48,7 +48,7 @@ impl ViewMode { #[derive(Debug)] pub struct EnvelopeView { pager: Option<Pager>, - subview: Option<Box<Component>>, + subview: Option<Box<dyn Component>>, dirty: bool, mode: ViewMode, wrapper: EnvelopeWrapper, @@ -69,7 +69,7 @@ impl EnvelopeView { pub fn new( wrapper: EnvelopeWrapper, pager: Option<Pager>, - subview: Option<Box<Component>>, + subview: Option<Box<dyn Component>>, account_pos: usize, ) -> Self { EnvelopeView { diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index b150627a..d1eb7409 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -30,8 +30,8 @@ pub use self::widgets::*; /// A horizontally split in half container. #[derive(Debug)] pub struct HSplit { - top: Box<Component>, - bottom: Box<Component>, + top: Box<dyn Component>, + bottom: Box<dyn Component>, show_divider: bool, ratio: usize, // bottom/whole height * 100 id: ComponentId, @@ -46,8 +46,8 @@ impl fmt::Display for HSplit { impl HSplit { pub fn new( - top: Box<Component>, - bottom: Box<Component>, + top: Box<dyn Component>, + bottom: Box<dyn Component>, ratio: usize, show_divider: bool, ) -> Self { @@ -125,8 +125,8 @@ impl Component for HSplit { /// A vertically split in half container. #[derive(Debug)] pub struct VSplit { - left: Box<Component>, - right: Box<Component>, + left: Box<dyn Component>, + right: Box<dyn Component>, show_divider: bool, prev_visibility: (bool, bool), /// This is the width of the right container to the entire width. @@ -143,8 +143,8 @@ impl fmt::Display for VSplit { impl VSplit { pub fn new( - left: Box<Component>, - right: Box<Component>, + left: Box<dyn Component>, + right: Box<dyn Component>, ratio: usize, show_divider: bool, ) -> Self { @@ -602,7 +602,7 @@ impl Component for Pager { /// Status bar. #[derive(Debug)] pub struct StatusBar { - container: Box<Component>, + container: Box<dyn Component>, status: String, notifications: VecDeque<String>, ex_buffer: Field, @@ -624,7 +624,7 @@ impl fmt::Display for StatusBar { } impl StatusBar { - pub fn new(container: Box<Component>) -> Self { + pub fn new(container: Box<dyn Component>) -> Self { StatusBar { container, status: String::with_capacity(256), @@ -1120,7 +1120,7 @@ impl Component for Progress { #[derive(Debug)] pub struct Tabbed { pinned: usize, - children: Vec<Box<Component>>, + children: Vec<Box<dyn Component>>, cursor_pos: usize, show_shortcuts: bool, @@ -1130,7 +1130,7 @@ pub struct Tabbed { } impl Tabbed { - pub fn new(children: Vec<Box<Component>>) -> Self { + pub fn new(children: Vec<Box<dyn Component>>) -> Self { let pinned = children.len(); Tabbed { pinned, @@ -1194,7 +1194,7 @@ impl Tabbed { context.dirty_areas.push_back(area); } - pub fn add_component(&mut self, new: Box<Component>) { + pub fn add_component(&mut self, new: Box<dyn Component>) { self.children.push(new); } } diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs index b84f0ea2..387fd906 100644 --- a/ui/src/components/utilities/widgets.rs +++ b/ui/src/components/utilities/widgets.rs @@ -1,7 +1,7 @@ use super::*; use fnv::FnvHashMap; -type AutoCompleteFn = Box<Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send>; +type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send>; #[derive(Debug, PartialEq)] enum FormFocus { diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index 4f84f8eb..3a0525ba 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -317,7 +317,7 @@ impl Account { } fn new_worker( folder: Folder, - backend: &mut Box<MailBackend>, + backend: &mut Box<dyn MailBackend>, notify_fn: Arc<NotifyFn>, ) -> Worker { let mailbox_handle = backend.get(&folder); @@ -617,7 +617,7 @@ impl Account { pub fn contains_key(&self, h: EnvelopeHash) -> bool { self.collection.contains_key(&h) } - pub fn operation(&self, h: EnvelopeHash) -> Box<BackendOp> { + pub fn operation(&self, h: EnvelopeHash) -> Box<dyn BackendOp> { for mailbox in self.folders.values() { match mailbox { MailboxEntry::Available(ref m) | MailboxEntry::Parsing(ref m, _, _) => { diff --git a/ui/src/execute/actions.rs b/ui/src/execute/actions.rs index ec62db90..02074bef 100644 --- a/ui/src/execute/actions.rs +++ b/ui/src/execute/actions.rs @@ -45,7 +45,7 @@ pub enum ListingAction { #[derive(Debug)] pub enum TabAction { - New(Option<Box<Component>>), + New(Option<Box<dyn Component>>), NewDraft(usize, Option<Draft>), Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash Close, diff --git a/ui/src/state.rs b/ui/src/state.rs index 9fd5ae47..27084608 100644 --- a/ui/src/state.rs +++ b/ui/src/state.rs @@ -21,7 +21,7 @@ /*! The application's state. -The UI crate has an Box<Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct. +The UI crate has an Box<dyn Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct. `State` owns all the Components of the UI. In the application's main event loop, input is handed to the state in the form of `UIEvent` objects which traverse the component graph. Components decide to handle each input or not. @@ -128,7 +128,7 @@ pub struct State { stdout: Option<StateStdout>, child: Option<ForkType>, pub mode: UIMode, - components: Vec<Box<Component>>, + components: Vec<Box<dyn Component>>, pub context: Context, threads: FnvHashMap<thread::ThreadId, (chan::Sender<bool>, thread::JoinHandle<()>)>, work_controller: WorkController, @@ -477,7 +477,7 @@ impl State { ); } } - pub fn register_component(&mut self, component: Box<Component>) { + pub fn register_component(&mut self, component: Box<dyn Component>) { self.components.push(component); } /// Convert user commands to actions/method calls. |