meli: clippy lint fixes

pull/237/head
Manos Pitsidianakis 11 months ago
parent 5f29faa640
commit 0b258a1f05
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

4
Cargo.lock generated

@ -1995,9 +1995,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]] [[package]]
name = "svg" name = "svg"
version = "0.10.0" version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e72d8b19ab05827afefcca66bf47040c1e66a0901eb814784c77d4ec118bd309" checksum = "02d815ad337e8449d2374d4248448645edfe74e699343dd5719139d93fa87112"
[[package]] [[package]]
name = "syn" name = "syn"

@ -49,7 +49,7 @@ signal-hook = { version = "^0.3", default-features = false }
signal-hook-registry = { version = "1.2.0", default-features = false } signal-hook-registry = { version = "1.2.0", default-features = false }
smallvec = { version = "^1.5.0", features = ["serde", ] } smallvec = { version = "^1.5.0", features = ["serde", ] }
structopt = { version = "0.3.14", default-features = false } 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 } termion = { version = "1.5.1", default-features = false }
toml = { version = "0.5.6", default-features = false, features = ["preserve_order", ] } toml = { version = "0.5.6", default-features = false, features = ["preserve_order", ] }
unicode-segmentation = "1.2.1" # >:c unicode-segmentation = "1.2.1" # >:c

@ -1436,15 +1436,13 @@ impl Component for Composer {
ViewMode::SelectEncryptKey(is_encrypt, ref mut selector), ViewMode::SelectEncryptKey(is_encrypt, ref mut selector),
UIEvent::FinishedUIDialog(id, result), UIEvent::FinishedUIDialog(id, result),
) if *id == selector.id() => { ) if *id == selector.id() => {
if let Some(key) = result.downcast_mut::<Option<melib::gpgme::Key>>() { if let Some(Some(key)) = result.downcast_mut::<Option<melib::gpgme::Key>>() {
if let Some(key) = key { if *is_encrypt {
if *is_encrypt { self.gpg_state.encrypt_keys.clear();
self.gpg_state.encrypt_keys.clear(); self.gpg_state.encrypt_keys.push(key.clone());
self.gpg_state.encrypt_keys.push(key.clone()); } else {
} else { self.gpg_state.sign_keys.clear();
self.gpg_state.sign_keys.clear(); self.gpg_state.sign_keys.push(key.clone());
self.gpg_state.sign_keys.push(key.clone());
}
} }
} }
self.mode = ViewMode::Edit; self.mode = ViewMode::Edit;

@ -26,6 +26,7 @@ use melib::email::headers::HeaderName;
use super::*; use super::*;
#[allow(clippy::type_complexity)]
pub enum HookFn { pub enum HookFn {
/// Stateful hook. /// Stateful hook.
Closure(Box<dyn FnMut(&mut Context, &mut Draft) -> Result<()> + Send + Sync>), Closure(Box<dyn FnMut(&mut Context, &mut Draft) -> Result<()> + Send + Sync>),

@ -1195,7 +1195,7 @@ impl Component for Listing {
to, to,
ref content, ref content,
} if (*from, *to) == (self.component.id(), self.id()) => { } if (*from, *to) == (self.component.id(), self.id()) => {
match content.downcast_ref::<ListingMessage>().map(|msg| *msg) { match content.downcast_ref::<ListingMessage>().copied() {
None => {} None => {}
Some(ListingMessage::FocusUpdate { new_value }) => { Some(ListingMessage::FocusUpdate { new_value }) => {
self.view.process_event( self.view.process_event(
@ -1241,7 +1241,7 @@ impl Component for Listing {
log::debug!( log::debug!(
"BUG intracomm event: {:?} downcast content {:?}", "BUG intracomm event: {:?} downcast content {:?}",
event, event,
content.downcast_ref::<ListingMessage>().map(|msg| *msg) content.downcast_ref::<ListingMessage>().copied()
); );
log::debug!( log::debug!(
"BUG component is {} and self id is {}", "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.focus == ListingFocus::Mailbox && self.status.is_none())
if self.component.unfocused() && self.view.process_event(event, context) { && ((self.component.unfocused() && self.view.process_event(event, context))
return true; || self.component.process_event(event, context))
} else if self.component.process_event(event, context) { {
return true; return true;
}
} }
let shortcuts = self.shortcuts(context); let shortcuts = self.shortcuts(context);
@ -2239,7 +2238,7 @@ impl Listing {
first_account_hash, first_account_hash,
MailboxHash::default(), MailboxHash::default(),
))), ))),
view: Box::new(ThreadView::default()), view: Box::<ThreadView>::default(),
accounts: account_entries, accounts: account_entries,
status: None, status: None,
dirty: true, dirty: true,

@ -971,6 +971,7 @@ impl CompactListing {
}) })
} }
#[allow(clippy::too_many_arguments)]
fn make_entry_string( fn make_entry_string(
&self, &self,
root_envelope: &Envelope, root_envelope: &Envelope,

@ -711,6 +711,7 @@ impl ConversationsListing {
}) })
} }
#[allow(clippy::too_many_arguments)]
pub(super) fn make_entry_string( pub(super) fn make_entry_string(
&self, &self,
root_envelope: &Envelope, root_envelope: &Envelope,

@ -107,7 +107,9 @@ impl MailView {
log::trace!("MailView::init_futures"); log::trace!("MailView::init_futures");
self.theme_default = crate::conf::value(context, "mail.view.body"); self.theme_default = crate::conf::value(context, "mail.view.body");
let mut pending_action = None; 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]; let account = &mut context.accounts[&coordinates.0];
if account.contains_key(coordinates.2) { if account.contains_key(coordinates.2) {
{ {
@ -194,7 +196,9 @@ impl MailView {
} }
fn perform_action(&mut self, action: PendingReplyAction, context: &mut Context) { 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 { let (bytes, reply_body, env) = match self.state {
MailViewState::Init { MailViewState::Init {
ref mut pending_action, ref mut pending_action,
@ -214,7 +218,7 @@ impl MailView {
.. ..
} => ( } => (
bytes, bytes,
env_view.attachment_displays_to_text(&env_view.display, false), EnvelopeView::attachment_displays_to_text(&env_view.display, false),
env, env,
), ),
MailViewState::Error { .. } => { MailViewState::Error { .. } => {
@ -257,7 +261,9 @@ impl MailView {
} }
fn start_contact_selector(&mut self, context: &mut Context) { 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]; let account = &context.accounts[&coordinates.0];
if !account.contains_key(coordinates.2) { if !account.contains_key(coordinates.2) {
context context
@ -297,7 +303,9 @@ impl Component for MailView {
if !self.is_dirty() { if !self.is_dirty() {
return; return;
} }
let Some(coordinates) = self.coordinates else { return; }; let Some(coordinates) = self.coordinates else {
return;
};
{ {
let account = &context.accounts[&coordinates.0]; 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 { 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() { if coordinates.0.is_null() || coordinates.1.is_null() {
return false; return false;
} }

@ -361,7 +361,7 @@ impl EnvelopeView {
(&self.force_charset).into(), (&self.force_charset).into(),
); );
let (attachment_paths, attachment_tree) = self.attachment_displays_to_tree(&display); 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.display = display;
self.body_text = body_text; self.body_text = body_text;
self.attachment_tree = attachment_tree; self.attachment_tree = attachment_tree;
@ -369,7 +369,6 @@ impl EnvelopeView {
} }
pub fn attachment_displays_to_text( pub fn attachment_displays_to_text(
&self,
displays: &[AttachmentDisplay], displays: &[AttachmentDisplay],
show_comments: bool, show_comments: bool,
) -> String { ) -> String {
@ -382,7 +381,7 @@ impl EnvelopeView {
shown_display, shown_display,
display, display,
} => { } => {
acc.push_str(&self.attachment_displays_to_text( acc.push_str(&Self::attachment_displays_to_text(
&display[*shown_display..(*shown_display + 1)], &display[*shown_display..(*shown_display + 1)],
show_comments, show_comments,
)); ));
@ -422,13 +421,13 @@ impl EnvelopeView {
if show_comments { if show_comments {
acc.push_str("Waiting for signature verification.\n\n"); 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 } => { SignedUnverified { inner: _, display } => {
if show_comments { if show_comments {
acc.push_str("Unverified signature.\n\n"); 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 { SignedFailed {
inner: _, inner: _,
@ -438,7 +437,7 @@ impl EnvelopeView {
if show_comments { if show_comments {
let _ = writeln!(acc, "Failed to verify signature: {}.\n", error); 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 { SignedVerified {
inner: _, inner: _,
@ -453,7 +452,7 @@ impl EnvelopeView {
acc.push_str("\n\n"); 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."), EncryptedPending { .. } => acc.push_str("Waiting for decryption result."),
EncryptedFailed { inner: _, error } => { EncryptedFailed { inner: _, error } => {
@ -473,9 +472,10 @@ impl EnvelopeView {
acc.push_str("\n\n"); acc.push_str("\n\n");
} }
} }
acc.push_str( acc.push_str(&Self::attachment_displays_to_text(
&self.attachment_displays_to_text(plaintext_display, show_comments), plaintext_display,
); show_comments,
));
} }
} }
} }
@ -1004,7 +1004,7 @@ impl Component for EnvelopeView {
ref archive, ref archive,
ref post, ref post,
ref unsubscribe, ref unsubscribe,
}) = list_management::ListActions::detect(&envelope) }) = list_management::ListActions::detect(envelope)
{ {
let mut x = get_x(upper_left); let mut x = get_x(upper_left);
if let Some(id) = id { if let Some(id) = id {

@ -55,7 +55,9 @@ pub enum MailViewState {
impl MailViewState { impl MailViewState {
pub fn load_bytes(self_: &mut MailView, bytes: Vec<u8>, context: &mut Context) { pub fn load_bytes(self_: &mut MailView, bytes: Vec<u8>, context: &mut Context) {
let Some(coordinates) = self_.coordinates else { return; }; let Some(coordinates) = self_.coordinates else {
return;
};
let account = &mut context.accounts[&coordinates.0]; let account = &mut context.accounts[&coordinates.0];
if account if account
.collection .collection

@ -86,9 +86,9 @@ pub enum ForceCharset {
Forced(Charset), Forced(Charset),
} }
impl Into<Option<Charset>> for &ForceCharset { impl From<&ForceCharset> for Option<Charset> {
fn into(self) -> Option<Charset> { fn from(val: &ForceCharset) -> Self {
match self { match val {
ForceCharset::Forced(val) => Some(*val), ForceCharset::Forced(val) => Some(*val),
ForceCharset::None | ForceCharset::Dialog(_) => None, ForceCharset::None | ForceCharset::Dialog(_) => None,
} }

@ -43,6 +43,12 @@ impl SVGScreenshotFilter {
} }
} }
impl Default for SVGScreenshotFilter {
fn default() -> Self {
Self::new()
}
}
impl Component for SVGScreenshotFilter { impl Component for SVGScreenshotFilter {
fn draw(&mut self, _grid: &mut CellBuffer, _area: Area, context: &mut Context) { fn draw(&mut self, _grid: &mut CellBuffer, _area: Area, context: &mut Context) {
if !self.save_screenshot { if !self.save_screenshot {

@ -171,7 +171,7 @@ pub fn view(
let mut state = State::new( let mut state = State::new(
Some(Settings::without_accounts().unwrap_or_default()), Some(Settings::without_accounts().unwrap_or_default()),
sender, sender,
receiver.clone(), receiver,
)?; )?;
let main_loop_handler = state.context.main_loop_handler.clone(); let main_loop_handler = state.context.main_loop_handler.clone();
state.register_component(Box::new(EnvelopeView::new( state.register_component(Box::new(EnvelopeView::new(

@ -94,7 +94,7 @@ struct EmbedContainer {
} }
impl EmbedContainer { impl EmbedContainer {
fn new(command: String) -> Box<dyn Component> { fn new(command: String) -> Box<Self> {
Box::new(Self { Box::new(Self {
command, command,
embed: None, embed: None,

Loading…
Cancel
Save