meli: clippy lint fixes

pull/237/head
Manos Pitsidianakis 2023-07-01 20:11:22 +03:00
parent 5f29faa640
commit 0b258a1f05
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
14 changed files with 62 additions and 44 deletions

4
Cargo.lock generated
View File

@ -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"

View File

@ -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

View File

@ -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::<Option<melib::gpgme::Key>>() {
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::<Option<melib::gpgme::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());
}
}
self.mode = ViewMode::Edit;

View File

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

View File

@ -1195,7 +1195,7 @@ impl Component for Listing {
to,
ref content,
} if (*from, *to) == (self.component.id(), self.id()) => {
match content.downcast_ref::<ListingMessage>().map(|msg| *msg) {
match content.downcast_ref::<ListingMessage>().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::<ListingMessage>().map(|msg| *msg)
content.downcast_ref::<ListingMessage>().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::<ThreadView>::default(),
accounts: account_entries,
status: None,
dirty: true,

View File

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

View File

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

View File

@ -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;
}

View File

@ -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 {

View File

@ -55,7 +55,9 @@ pub enum MailViewState {
impl MailViewState {
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];
if account
.collection

View File

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

View File

@ -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 {

View File

@ -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(

View File

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