Fix clippy lints for `meli` crate

pull/150/head
Manos Pitsidianakis 2022-09-11 15:19:40 +03:00
parent 388d4e35d6
commit 94bd84b45d
25 changed files with 60 additions and 54 deletions

View File

@ -39,7 +39,7 @@ fn main() {
{
use flate2::Compression;
use flate2::GzBuilder;
const MANDOC_OPTS: &[&'static str] = &["-T", "utf8", "-I", "os=Generated by mandoc(1)"];
const MANDOC_OPTS: &[&str] = &["-T", "utf8", "-I", "os=Generated by mandoc(1)"];
use std::env;
use std::fs::File;
use std::io::prelude::*;

View File

@ -66,7 +66,7 @@ pub enum PageMovement {
End,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ScrollContext {
shown_lines: usize,
total_lines: usize,

View File

@ -25,7 +25,7 @@ use melib::CardId;
use std::cmp;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
enum ViewMode {
List,
View(ComponentId),

View File

@ -41,7 +41,7 @@ mod gpg;
mod edit_attachments;
use edit_attachments::*;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
enum Cursor {
Headers,
Body,
@ -227,7 +227,7 @@ impl Composer {
)
.as_ref()
.map(|v| v.iter().map(String::as_str).collect::<Vec<&str>>())
.unwrap_or(vec![]);
.unwrap_or_default();
let subject = subject
.as_ref()
.strip_prefixes_from_list(if prefix_list.is_empty() {
@ -242,7 +242,7 @@ impl Composer {
if !subject.starts_with(prefix) {
format!("{prefix} {subject}", prefix = prefix, subject = subject)
} else {
subject.to_string()
subject
}
};
ret.draft.set_header("Subject", subject);
@ -1114,7 +1114,7 @@ impl Component for Composer {
Some(Box::new(move |id: ComponentId, results: &[char]| {
Some(UIEvent::FinishedUIDialog(
id,
Box::new(results.get(0).cloned().unwrap_or('c')),
Box::new(results.first().cloned().unwrap_or('c')),
))
})),
context,
@ -2044,7 +2044,7 @@ impl Component for Composer {
Some(Box::new(move |id: ComponentId, results: &[char]| {
Some(UIEvent::FinishedUIDialog(
id,
Box::new(results.get(0).copied().unwrap_or('n')),
Box::new(results.first().copied().unwrap_or('n')),
))
})),
context,
@ -2093,7 +2093,7 @@ impl Component for Composer {
Some(Box::new(move |id: ComponentId, results: &[char]| {
Some(UIEvent::FinishedUIDialog(
id,
Box::new(results.get(0).copied().unwrap_or('n')),
Box::new(results.first().copied().unwrap_or('n')),
))
})),
context,

View File

@ -21,7 +21,7 @@
use super::*;
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum EditAttachmentCursor {
AttachmentNo(usize),
Buttons,

View File

@ -68,7 +68,7 @@ pub enum Focus {
EntryFullscreen,
}
#[derive(Debug, Copy, PartialEq, Clone)]
#[derive(Debug, Copy, PartialEq, Eq, Clone)]
pub enum Modifier {
SymmetricDifference,
Union,
@ -594,19 +594,19 @@ impl ListingComponent {
}
}
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
enum ListingFocus {
Menu,
Mailbox,
}
#[derive(PartialEq, Copy, Clone, Debug)]
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
enum MenuEntryCursor {
Status,
Mailbox(usize),
}
#[derive(PartialEq, Copy, Clone, Debug)]
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
enum ShowMenuScrollbar {
Never,
True,

View File

@ -697,7 +697,7 @@ impl ConversationsListing {
if !acc.is_empty() {
acc.push_str(", ");
}
acc.push_str(&s);
acc.push_str(s);
acc
})
} else {

View File

@ -23,6 +23,7 @@ use super::*;
use crate::components::PageMovement;
use std::cmp;
use std::convert::TryInto;
use std::fmt::Write;
macro_rules! row_attr {
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
@ -883,7 +884,7 @@ impl ThreadListing {
});
*/
if show_subject {
s.push_str(&format!("{:.85}", envelope.subject()));
let _ = write!(s, "{:.85}", envelope.subject());
}
s
}

View File

@ -27,6 +27,7 @@ use melib::list_management;
use melib::parser::BytesExt;
use smallvec::SmallVec;
use std::collections::HashSet;
use std::fmt::Write as _;
use std::io::Write;
use std::convert::TryFrom;
@ -44,7 +45,7 @@ pub use self::envelope::*;
use linkify::LinkFinder;
use xdg_utils::query_default_app;
#[derive(PartialEq, Copy, Clone, Debug)]
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
enum Source {
Decoded,
Raw,
@ -530,7 +531,7 @@ impl MailView {
error,
} => {
if show_comments {
acc.push_str(&format!("Failed to verify signature: {}.\n\n", error));
let _ = writeln!(acc, "Failed to verify signature: {}.\n", error);
}
acc.push_str(&self.attachment_displays_to_text(
display,
@ -559,7 +560,7 @@ impl MailView {
}
EncryptedPending { .. } => acc.push_str("Waiting for decryption result."),
EncryptedFailed { inner: _, error } => {
acc.push_str(&format!("Decryption failed: {}.", &error))
let _ = write!(acc, "Decryption failed: {}.", &error);
}
EncryptedSuccess {
inner: _,

View File

@ -25,7 +25,7 @@ use std::process::{Command, Stdio};
use xdg_utils::query_default_app;
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
enum ViewMode {
Normal,
Url,
@ -134,7 +134,7 @@ impl EnvelopeView {
.iter()
.enumerate()
.fold(t, |mut s, (idx, a)| {
s.push_str(&format!("[{}] {}\n\n", idx, a));
let _ = writeln!(s, "[{}] {}\n", idx, a);
s
});
}
@ -161,7 +161,7 @@ impl EnvelopeView {
.iter()
.enumerate()
.fold(t, |mut s, (idx, a)| {
s.push_str(&format!("[{}] {}\n\n", idx, a));
let _ = writeln!(s, "[{}] {}\n", idx, a);
s
});
}

View File

@ -105,7 +105,7 @@ impl HtmlView {
.iter()
.enumerate()
.fold(display_text, |mut s, (idx, a)| {
s.push_str(&format!("[{}] {}\n\n\n", idx, a));
let _ = writeln!(s, "[{}] {}\n\n", idx, a);
s
});
}

View File

@ -151,13 +151,14 @@ mod dbus {
'"' => ret.push_str("&quot;"),
_ => {
let i = c as u32;
if (0x1 <= i && i <= 0x8)
|| (0xb <= i && i <= 0xc)
|| (0xe <= i && i <= 0x1f)
|| (0x7f <= i && i <= 0x84)
|| (0x86 <= i && i <= 0x9f)
if (0x1..=0x8).contains(&i)
|| (0xb..=0xc).contains(&i)
|| (0xe..=0x1f).contains(&i)
|| (0x7f..=0x84).contains(&i)
|| (0x86..=0x9f).contains(&i)
{
ret.push_str(&format!("&#{:x}%{:x};", i, i));
use std::fmt::Write;
let _ = write!(ret, "&#{:x}%{:x};", i, i);
} else {
ret.push(c);
}

View File

@ -1547,7 +1547,7 @@ impl Component for Tabbed {
}
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawBuffer {
pub buf: CellBuffer,
title: Option<String>,

View File

@ -27,7 +27,7 @@ const OK_LENGTH: usize = "OK".len();
const CANCEL_OFFSET: usize = "OK ".len();
const CANCEL_LENGTH: usize = "Cancel".len();
#[derive(Debug, Copy, PartialEq, Clone)]
#[derive(Debug, Copy, PartialEq, Eq, Clone)]
enum SelectorCursor {
Unfocused,
/// Cursor is at an entry

View File

@ -26,7 +26,7 @@ use std::time::Duration;
type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send + Sync>;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
enum FormFocus {
Fields,
Buttons,
@ -390,7 +390,7 @@ impl fmt::Display for Field {
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum FormButtonActions {
Accept,
Reset,
@ -870,7 +870,7 @@ where
}
}
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct AutoCompleteEntry {
pub entry: String,
pub description: String,
@ -911,7 +911,7 @@ impl From<(String, String)> for AutoCompleteEntry {
}
}
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct AutoComplete {
entries: Vec<AutoCompleteEntry>,
content: CellBuffer,

View File

@ -573,7 +573,7 @@ impl Settings {
}
}
#[derive(Copy, Debug, Clone, Hash, PartialEq)]
#[derive(Copy, Debug, Clone, Hash, PartialEq, Eq)]
pub enum IndexStyle {
Plain,
Threaded,
@ -703,7 +703,7 @@ impl Serialize for IndexStyle {
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum SearchBackend {
None,
Auto,

View File

@ -1204,11 +1204,11 @@ impl Account {
),
melib::INFO,
);
return Err(MeliError::new(format!(
Err(MeliError::new(format!(
"Message was stored in {} so that you can restore it manually.",
file.path.display()
))
.set_summary("Could not save in any mailbox"));
.set_summary("Could not save in any mailbox"))
}
}

View File

@ -36,6 +36,7 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::collections::HashSet;
use std::fmt::Write;
#[inline(always)]
pub fn value(context: &Context, key: &'static str) -> ThemeAttribute {
@ -1240,26 +1241,28 @@ impl Themes {
t => self.other_themes.get(t).unwrap_or(&self.dark),
};
let mut ret = String::new();
ret.push_str(&format!("[terminal.themes.{}]\n", key));
let _ = writeln!(ret, "[terminal.themes.{}]", key);
if unlink {
for k in theme.keys() {
ret.push_str(&format!(
"\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}\n",
let _ = writeln!(
ret,
"\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}",
k,
toml::to_string(&unlink_fg(theme, &ColorField::Fg, k)).unwrap(),
toml::to_string(&unlink_bg(theme, &ColorField::Bg, k)).unwrap(),
toml::to_string(&unlink_attrs(theme, k)).unwrap(),
));
);
}
} else {
for k in theme.keys() {
ret.push_str(&format!(
"\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}\n",
let _ = writeln!(
ret,
"\"{}\" = {{ fg = {}, bg = {}, attrs = {} }}",
k,
toml::to_string(&theme[k].fg).unwrap(),
toml::to_string(&theme[k].bg).unwrap(),
toml::to_string(&theme[k].attrs).unwrap(),
));
);
}
}
ret

View File

@ -36,7 +36,7 @@ pub use rpc::*;
pub const BACKEND_FN: i8 = 0;
pub const BACKEND_OP_FN: i8 = 1;
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PluginKind {
LongLived,
Filter,

View File

@ -456,7 +456,7 @@ impl<'de> Deserialize<'de> for Color {
#[test]
fn test_color_de() {
#[derive(Debug, Deserialize, PartialEq)]
#[derive(Debug, Deserialize, PartialEq, Eq)]
struct V {
k: Color,
}

View File

@ -179,7 +179,7 @@ impl EmbedTerminal {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
enum CodepointBuf {
None,
TwoCodepoints(u8),

View File

@ -139,7 +139,7 @@ impl PartialEq<Key> for &Key {
}
}
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
/// Keep track of whether we're accepting normal user input or a pasted string.
enum InputMode {
Normal,
@ -359,7 +359,7 @@ impl Serialize for Key {
#[test]
fn test_key_serde() {
#[derive(Debug, Deserialize, PartialEq)]
#[derive(Debug, Deserialize, PartialEq, Eq)]
struct V {
k: Key,
}

View File

@ -170,7 +170,7 @@ pub fn center_area(area: Area, (width, height): (usize, usize)) -> Area {
)
}
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Alignment {
/// Stretch to fill all space if possible, center if no meaningful way to stretch.
Fill,

View File

@ -21,7 +21,7 @@
use melib::text_processing::TextProcessing;
#[derive(Debug, Clone, Default, PartialEq)]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct UText {
content: String,
cursor_pos: usize,

View File

@ -169,7 +169,7 @@ impl From<RefreshEvent> for UIEvent {
}
}
#[derive(Debug, PartialEq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum UIMode {
Normal,
Insert,