diff --git a/Cargo.lock b/Cargo.lock index 0fc85115..542f35d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1995,9 +1995,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "svg" -version = "0.10.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72d8b19ab05827afefcca66bf47040c1e66a0901eb814784c77d4ec118bd309" +checksum = "02d815ad337e8449d2374d4248448645edfe74e699343dd5719139d93fa87112" [[package]] name = "syn" diff --git a/Cargo.toml b/Cargo.toml index b25df37a..490442e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ signal-hook = { version = "^0.3", default-features = false } signal-hook-registry = { version = "1.2.0", default-features = false } smallvec = { version = "^1.5.0", features = ["serde", ] } structopt = { version = "0.3.14", default-features = false } -svg_crate = { version = "^0.10", optional = true, package = "svg" } +svg_crate = { version = "^0.13", optional = true, package = "svg" } termion = { version = "1.5.1", default-features = false } toml = { version = "0.5.6", default-features = false, features = ["preserve_order", ] } unicode-segmentation = "1.2.1" # >:c diff --git a/src/components/mail/compose.rs b/src/components/mail/compose.rs index 8045a695..b17221f6 100644 --- a/src/components/mail/compose.rs +++ b/src/components/mail/compose.rs @@ -1436,15 +1436,13 @@ impl Component for Composer { ViewMode::SelectEncryptKey(is_encrypt, ref mut selector), UIEvent::FinishedUIDialog(id, result), ) if *id == selector.id() => { - if let Some(key) = result.downcast_mut::>() { - if let Some(key) = key { - if *is_encrypt { - self.gpg_state.encrypt_keys.clear(); - self.gpg_state.encrypt_keys.push(key.clone()); - } else { - self.gpg_state.sign_keys.clear(); - self.gpg_state.sign_keys.push(key.clone()); - } + if let Some(Some(key)) = result.downcast_mut::>() { + if *is_encrypt { + self.gpg_state.encrypt_keys.clear(); + self.gpg_state.encrypt_keys.push(key.clone()); + } else { + self.gpg_state.sign_keys.clear(); + self.gpg_state.sign_keys.push(key.clone()); } } self.mode = ViewMode::Edit; diff --git a/src/components/mail/compose/hooks.rs b/src/components/mail/compose/hooks.rs index cc5dffc3..3ce04ec0 100644 --- a/src/components/mail/compose/hooks.rs +++ b/src/components/mail/compose/hooks.rs @@ -26,6 +26,7 @@ use melib::email::headers::HeaderName; use super::*; +#[allow(clippy::type_complexity)] pub enum HookFn { /// Stateful hook. Closure(Box Result<()> + Send + Sync>), diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index ed7dd3a9..4565d61f 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -1195,7 +1195,7 @@ impl Component for Listing { to, ref content, } if (*from, *to) == (self.component.id(), self.id()) => { - match content.downcast_ref::().map(|msg| *msg) { + match content.downcast_ref::().copied() { None => {} Some(ListingMessage::FocusUpdate { new_value }) => { self.view.process_event( @@ -1241,7 +1241,7 @@ impl Component for Listing { log::debug!( "BUG intracomm event: {:?} downcast content {:?}", event, - content.downcast_ref::().map(|msg| *msg) + content.downcast_ref::().copied() ); log::debug!( "BUG component is {} and self id is {}", @@ -1264,12 +1264,11 @@ impl Component for Listing { } } } - if self.focus == ListingFocus::Mailbox && self.status.is_none() { - if self.component.unfocused() && self.view.process_event(event, context) { - return true; - } else if self.component.process_event(event, context) { - return true; - } + if (self.focus == ListingFocus::Mailbox && self.status.is_none()) + && ((self.component.unfocused() && self.view.process_event(event, context)) + || self.component.process_event(event, context)) + { + return true; } let shortcuts = self.shortcuts(context); @@ -2239,7 +2238,7 @@ impl Listing { first_account_hash, MailboxHash::default(), ))), - view: Box::new(ThreadView::default()), + view: Box::::default(), accounts: account_entries, status: None, dirty: true, diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index 90c67bc3..20fc28c9 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -971,6 +971,7 @@ impl CompactListing { }) } + #[allow(clippy::too_many_arguments)] fn make_entry_string( &self, root_envelope: &Envelope, diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs index f0b895a6..f6fcab2e 100644 --- a/src/components/mail/listing/conversations.rs +++ b/src/components/mail/listing/conversations.rs @@ -711,6 +711,7 @@ impl ConversationsListing { }) } + #[allow(clippy::too_many_arguments)] pub(super) fn make_entry_string( &self, root_envelope: &Envelope, diff --git a/src/components/mail/view.rs b/src/components/mail/view.rs index 13e2caee..df58dd67 100644 --- a/src/components/mail/view.rs +++ b/src/components/mail/view.rs @@ -107,7 +107,9 @@ impl MailView { log::trace!("MailView::init_futures"); self.theme_default = crate::conf::value(context, "mail.view.body"); let mut pending_action = None; - let Some(coordinates) = self.coordinates else { return; }; + let Some(coordinates) = self.coordinates else { + return; + }; let account = &mut context.accounts[&coordinates.0]; if account.contains_key(coordinates.2) { { @@ -194,7 +196,9 @@ impl MailView { } fn perform_action(&mut self, action: PendingReplyAction, context: &mut Context) { - let Some(coordinates) = self.coordinates else { return; }; + let Some(coordinates) = self.coordinates else { + return; + }; let (bytes, reply_body, env) = match self.state { MailViewState::Init { ref mut pending_action, @@ -214,7 +218,7 @@ impl MailView { .. } => ( bytes, - env_view.attachment_displays_to_text(&env_view.display, false), + EnvelopeView::attachment_displays_to_text(&env_view.display, false), env, ), MailViewState::Error { .. } => { @@ -257,7 +261,9 @@ impl MailView { } fn start_contact_selector(&mut self, context: &mut Context) { - let Some(coordinates) = self.coordinates else { return; }; + let Some(coordinates) = self.coordinates else { + return; + }; let account = &context.accounts[&coordinates.0]; if !account.contains_key(coordinates.2) { context @@ -297,7 +303,9 @@ impl Component for MailView { if !self.is_dirty() { return; } - let Some(coordinates) = self.coordinates else { return; }; + let Some(coordinates) = self.coordinates else { + return; + }; { let account = &context.accounts[&coordinates.0]; @@ -339,7 +347,9 @@ impl Component for MailView { } fn process_event(&mut self, mut event: &mut UIEvent, context: &mut Context) -> bool { - let Some(coordinates) = self.coordinates else { return false; }; + let Some(coordinates) = self.coordinates else { + return false; + }; if coordinates.0.is_null() || coordinates.1.is_null() { return false; } diff --git a/src/components/mail/view/envelope.rs b/src/components/mail/view/envelope.rs index 90095517..1aed0c6f 100644 --- a/src/components/mail/view/envelope.rs +++ b/src/components/mail/view/envelope.rs @@ -361,7 +361,7 @@ impl EnvelopeView { (&self.force_charset).into(), ); let (attachment_paths, attachment_tree) = self.attachment_displays_to_tree(&display); - let body_text = self.attachment_displays_to_text(&display, true); + let body_text = Self::attachment_displays_to_text(&display, true); self.display = display; self.body_text = body_text; self.attachment_tree = attachment_tree; @@ -369,7 +369,6 @@ impl EnvelopeView { } pub fn attachment_displays_to_text( - &self, displays: &[AttachmentDisplay], show_comments: bool, ) -> String { @@ -382,7 +381,7 @@ impl EnvelopeView { shown_display, display, } => { - acc.push_str(&self.attachment_displays_to_text( + acc.push_str(&Self::attachment_displays_to_text( &display[*shown_display..(*shown_display + 1)], show_comments, )); @@ -422,13 +421,13 @@ impl EnvelopeView { if show_comments { acc.push_str("Waiting for signature verification.\n\n"); } - acc.push_str(&self.attachment_displays_to_text(display, show_comments)); + acc.push_str(&Self::attachment_displays_to_text(display, show_comments)); } SignedUnverified { inner: _, display } => { if show_comments { acc.push_str("Unverified signature.\n\n"); } - acc.push_str(&self.attachment_displays_to_text(display, show_comments)) + acc.push_str(&Self::attachment_displays_to_text(display, show_comments)) } SignedFailed { inner: _, @@ -438,7 +437,7 @@ impl EnvelopeView { if show_comments { let _ = writeln!(acc, "Failed to verify signature: {}.\n", error); } - acc.push_str(&self.attachment_displays_to_text(display, show_comments)); + acc.push_str(&Self::attachment_displays_to_text(display, show_comments)); } SignedVerified { inner: _, @@ -453,7 +452,7 @@ impl EnvelopeView { acc.push_str("\n\n"); } } - acc.push_str(&self.attachment_displays_to_text(display, show_comments)); + acc.push_str(&Self::attachment_displays_to_text(display, show_comments)); } EncryptedPending { .. } => acc.push_str("Waiting for decryption result."), EncryptedFailed { inner: _, error } => { @@ -473,9 +472,10 @@ impl EnvelopeView { acc.push_str("\n\n"); } } - acc.push_str( - &self.attachment_displays_to_text(plaintext_display, show_comments), - ); + acc.push_str(&Self::attachment_displays_to_text( + plaintext_display, + show_comments, + )); } } } @@ -1004,7 +1004,7 @@ impl Component for EnvelopeView { ref archive, ref post, ref unsubscribe, - }) = list_management::ListActions::detect(&envelope) + }) = list_management::ListActions::detect(envelope) { let mut x = get_x(upper_left); if let Some(id) = id { diff --git a/src/components/mail/view/state.rs b/src/components/mail/view/state.rs index 8fed73f3..68faf810 100644 --- a/src/components/mail/view/state.rs +++ b/src/components/mail/view/state.rs @@ -55,7 +55,9 @@ pub enum MailViewState { impl MailViewState { pub fn load_bytes(self_: &mut MailView, bytes: Vec, context: &mut Context) { - let Some(coordinates) = self_.coordinates else { return; }; + let Some(coordinates) = self_.coordinates else { + return; + }; let account = &mut context.accounts[&coordinates.0]; if account .collection diff --git a/src/components/mail/view/types.rs b/src/components/mail/view/types.rs index 190bc92b..5ff82822 100644 --- a/src/components/mail/view/types.rs +++ b/src/components/mail/view/types.rs @@ -86,9 +86,9 @@ pub enum ForceCharset { Forced(Charset), } -impl Into> for &ForceCharset { - fn into(self) -> Option { - match self { +impl From<&ForceCharset> for Option { + fn from(val: &ForceCharset) -> Self { + match val { ForceCharset::Forced(val) => Some(*val), ForceCharset::None | ForceCharset::Dialog(_) => None, } diff --git a/src/components/svg.rs b/src/components/svg.rs index fb493895..ffbaa661 100644 --- a/src/components/svg.rs +++ b/src/components/svg.rs @@ -43,6 +43,12 @@ impl SVGScreenshotFilter { } } +impl Default for SVGScreenshotFilter { + fn default() -> Self { + Self::new() + } +} + impl Component for SVGScreenshotFilter { fn draw(&mut self, _grid: &mut CellBuffer, _area: Area, context: &mut Context) { if !self.save_screenshot { diff --git a/src/subcommands.rs b/src/subcommands.rs index f6c027c1..ecc0fc36 100644 --- a/src/subcommands.rs +++ b/src/subcommands.rs @@ -171,7 +171,7 @@ pub fn view( let mut state = State::new( Some(Settings::without_accounts().unwrap_or_default()), sender, - receiver.clone(), + receiver, )?; let main_loop_handler = state.context.main_loop_handler.clone(); state.register_component(Box::new(EnvelopeView::new( diff --git a/tools/src/embed.rs b/tools/src/embed.rs index 41034dbc..2d658665 100644 --- a/tools/src/embed.rs +++ b/tools/src/embed.rs @@ -94,7 +94,7 @@ struct EmbedContainer { } impl EmbedContainer { - fn new(command: String) -> Box { + fn new(command: String) -> Box { Box::new(Self { command, embed: None,