diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2018-08-23 15:36:52 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:31 +0300 |
commit | 2b6d1e0dbf47750ee4377d532fb6b38496e4b336 (patch) | |
tree | 4d0dbb939d66ececb4629c00caa5f301d9930098 /ui/src/components/mail/listing | |
parent | b617fc013681f3c2a9b6f49fa6e2af8261bf99c7 (diff) |
Run clippy lints
Diffstat (limited to 'ui/src/components/mail/listing')
-rw-r--r-- | ui/src/components/mail/listing/compact.rs | 42 | ||||
-rw-r--r-- | ui/src/components/mail/listing/mod.rs | 29 |
2 files changed, 32 insertions, 39 deletions
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 96ab3d94..c9e3edd1 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -67,14 +67,14 @@ impl CompactListing { &CompactListing::format_date(e), e.subject(), len - ) + ) } else { format!( "{} {} {:.85}", idx, &CompactListing::format_date(e), e.subject(), - ) + ) } } @@ -86,7 +86,7 @@ impl CompactListing { length: 0, sort: (Default::default(), Default::default()), subsort: (Default::default(), Default::default()), - content: content, + content, dirty: true, unfocused: false, view: None, @@ -110,7 +110,10 @@ impl CompactListing { // loop { // TODO: Show progress visually - if let Ok(_) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { + if context.accounts[self.cursor_pos.0] + .status(self.cursor_pos.1) + .is_ok() + { break; } } @@ -118,7 +121,6 @@ impl CompactListing { .as_ref() .unwrap(); - self.length = mailbox.threads.root_len(); self.content = CellBuffer::new(MAX_COLS, self.length + 1, Cell::with_char(' ')); if self.length == 0 { @@ -139,9 +141,9 @@ impl CompactListing { let i = if let Some(i) = container.message() { i } else { - threads.containers()[ - container.first_child().unwrap() - ].message().unwrap() + threads.containers()[container.first_child().unwrap()] + .message() + .unwrap() }; let root_envelope: &Envelope = &mailbox.collection[i]; let fg_color = if has_unseen { @@ -163,16 +165,13 @@ impl CompactListing { bg_color, ((0, idx), (MAX_COLS - 1, idx)), false, - ); + ); for x in x..MAX_COLS { self.content[(x, idx)].set_ch(' '); self.content[(x, idx)].set_bg(bg_color); } - - } - } fn highlight_line(&self, grid: &mut CellBuffer, area: Area, idx: usize, context: &Context) { @@ -185,9 +184,9 @@ impl CompactListing { let i = if let Some(i) = container.message() { i } else { - threads.containers()[ - container.first_child().unwrap() - ].message().unwrap() + threads.containers()[container.first_child().unwrap()] + .message() + .unwrap() }; let root_envelope: &Envelope = &mailbox.collection[i]; let fg_color = if !root_envelope.is_seen() { @@ -303,11 +302,7 @@ impl Component for CompactListing { return; } self.view = Some(ThreadView::new(self.cursor_pos, context)); - self.view.as_mut().unwrap().draw( - grid, - area, - context, - ); + self.view.as_mut().unwrap().draw(grid, area, context); self.dirty = false; } } @@ -440,8 +435,7 @@ impl Component for CompactListing { self.dirty = true; self.refresh_mailbox(context); return true; - } - // _ => {} + } // _ => {} }, _ => {} } @@ -451,7 +445,9 @@ impl Component for CompactListing { self.dirty || self.view.as_ref().map(|p| p.is_dirty()).unwrap_or(false) } fn set_dirty(&mut self) { - self.view.as_mut().map(|p| p.set_dirty()); + if let Some(p) = self.view.as_mut() { + p.set_dirty(); + } self.dirty = true; } } diff --git a/ui/src/components/mail/listing/mod.rs b/ui/src/components/mail/listing/mod.rs index 132f4408..b109c599 100644 --- a/ui/src/components/mail/listing/mod.rs +++ b/ui/src/components/mail/listing/mod.rs @@ -79,7 +79,7 @@ impl MailListing { local_collection: Vec::new(), sort: (Default::default(), Default::default()), subsort: (Default::default(), Default::default()), - content: content, + content, dirty: true, unfocused: false, view: None, @@ -107,7 +107,10 @@ impl MailListing { // loop { // TODO: Show progress visually - if let Ok(_) = context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) { + if context.accounts[self.cursor_pos.0] + .status(self.cursor_pos.1) + .is_ok() + { break; } } @@ -162,7 +165,6 @@ impl MailListing { continue; } - match iter.peek() { Some(&x) if threads[x].indentation() == indentation => { indentations.pop(); @@ -198,7 +200,7 @@ impl MailListing { container, &indentations, len, - // context.accounts[self.cursor_pos.0].backend.operation(envelope.hash()) + // context.accounts[self.cursor_pos.0].backend.operation(envelope.hash()) ), &mut self.content, fg_color, @@ -522,9 +524,7 @@ impl Component for MailListing { .threaded(); let account = &mut context.accounts[self.cursor_pos.0]; let (hash, is_seen) = { - let mailbox = &mut account[self.cursor_pos.1] - .as_mut() - .unwrap(); + let mailbox = &mut account[self.cursor_pos.1].as_mut().unwrap(); let envelope: &mut Envelope = if threaded { let i = mailbox.threaded_mail(idx); &mut mailbox.collection[i] @@ -538,9 +538,7 @@ impl Component for MailListing { let backend = &account.backend; backend.operation(hash) }; - let mailbox = &mut account[self.cursor_pos.1] - .as_mut() - .unwrap(); + let mailbox = &mut account[self.cursor_pos.1].as_mut().unwrap(); let envelope: &mut Envelope = if threaded { let i = mailbox.threaded_mail(idx); &mut mailbox.collection[i] @@ -598,9 +596,7 @@ impl Component for MailListing { .conf() .threaded(); let account = &context.accounts[self.cursor_pos.0]; - let mailbox = &account[self.cursor_pos.1] - .as_ref() - .unwrap(); + let mailbox = &account[self.cursor_pos.1].as_ref().unwrap(); let mut coordinates = self.cursor_pos; coordinates.2 = if threaded { mailbox.threaded_mail(self.cursor_pos.2) @@ -792,8 +788,7 @@ impl Component for MailListing { self.dirty = true; self.refresh_mailbox(context); return true; - } - // _ => {} + } // _ => {} }, _ => {} } @@ -803,7 +798,9 @@ impl Component for MailListing { self.dirty || self.view.as_ref().map(|p| p.is_dirty()).unwrap_or(false) } fn set_dirty(&mut self) { - self.view.as_mut().map(|p| p.set_dirty()); + if let Some(p) = self.view.as_mut() { + p.set_dirty(); + }; self.dirty = true; } } |