From 8185f2cf7d539c714fd0a6128f40ba1fc9e0c43c Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 1 Jan 2024 15:23:22 +0200 Subject: [PATCH] meli: add deny clippy lints and fix them Signed-off-by: Manos Pitsidianakis --- meli/config_macros.rs | 2 +- meli/src/accounts.rs | 98 +- meli/src/accounts/backend_ops.rs | 2 +- meli/src/args.rs | 8 +- meli/src/command.rs | 20 +- meli/src/command/actions.rs | 8 +- meli/src/conf.rs | 56 +- meli/src/conf/composing.rs | 8 +- meli/src/conf/overrides.rs | 14 +- meli/src/conf/pgp.rs | 2 +- meli/src/conf/terminal.rs | 2 +- meli/src/conf/themes.rs | 84 +- meli/src/contacts/editor.rs | 6 +- meli/src/contacts/list.rs | 8 +- meli/src/jobs.rs | 4 +- meli/src/jobs_view.rs | 2 +- meli/src/lib.rs | 42 +- meli/src/mail/compose.rs | 49 +- meli/src/mail/compose/edit_attachments.rs | 2 +- meli/src/mail/compose/gpg.rs | 54 +- meli/src/mail/listing.rs | 18 +- meli/src/mail/listing/compact.rs | 2 +- meli/src/mail/listing/conversations.rs | 2 +- meli/src/mail/listing/offline.rs | 2 +- meli/src/mail/listing/plain.rs | 2 +- meli/src/mail/listing/thread.rs | 6 +- meli/src/mail/pgp.rs | 8 +- meli/src/mail/status.rs | 4 +- meli/src/mail/view.rs | 2 +- meli/src/mail/view/envelope.rs | 14 +- meli/src/mail/view/filters.rs | 14 +- meli/src/mail/view/state.rs | 6 +- meli/src/mail/view/thread.rs | 11 +- meli/src/mailbox_management.rs | 4 +- meli/src/mailcap.rs | 12 +- meli/src/notifications.rs | 13 +- meli/src/sqlite3.rs | 6 +- meli/src/state.rs | 12 +- meli/src/svg.rs | 14 +- meli/src/terminal/braille.rs | 2 +- meli/src/terminal/color.rs | 1108 ++++++++++----------- meli/src/terminal/embedded/terminal.rs | 2 +- meli/src/terminal/keys.rs | 80 +- meli/src/terminal/screen.rs | 9 +- meli/src/terminal/text_editing.rs | 2 +- meli/src/types.rs | 36 +- meli/src/utilities.rs | 15 +- meli/src/utilities/dialogs.rs | 2 +- meli/src/utilities/tables.rs | 2 +- meli/src/utilities/text.rs | 2 +- meli/src/utilities/widgets.rs | 24 +- 51 files changed, 969 insertions(+), 938 deletions(-) diff --git a/meli/config_macros.rs b/meli/config_macros.rs index 2c4eff98..bc1edfea 100644 --- a/meli/config_macros.rs +++ b/meli/config_macros.rs @@ -192,7 +192,7 @@ use melib::HeaderName; #(#attrs_tokens)* impl Default for #override_ident { fn default() -> Self { - #override_ident { + Self { #(#field_idents: None),* } } diff --git a/meli/src/accounts.rs b/meli/src/accounts.rs index 18804829..8dc341f2 100644 --- a/meli/src/accounts.rs +++ b/meli/src/accounts.rs @@ -287,34 +287,34 @@ pub enum JobRequest { impl Drop for JobRequest { fn drop(&mut self) { match self { - JobRequest::Generic { handle, .. } | - JobRequest::IsOnline { handle, .. } | - JobRequest::Refresh { handle, .. } | - JobRequest::SetFlags { handle, .. } | - JobRequest::SaveMessage { handle, .. } | + Self::Generic { handle, .. } | + Self::IsOnline { handle, .. } | + Self::Refresh { handle, .. } | + Self::SetFlags { handle, .. } | + Self::SaveMessage { handle, .. } | //JobRequest::RenameMailbox, - JobRequest::SetMailboxPermissions { handle, .. } | - JobRequest::SetMailboxSubscription { handle, .. } | - JobRequest::Watch { handle, .. } | - JobRequest::SendMessageBackground { handle, .. } => { + Self::SetMailboxPermissions { handle, .. } | + Self::SetMailboxSubscription { handle, .. } | + Self::Watch { handle, .. } | + Self::SendMessageBackground { handle, .. } => { handle.cancel(); } - JobRequest::DeleteMessages { handle, .. } => { + Self::DeleteMessages { handle, .. } => { handle.cancel(); } - JobRequest::CreateMailbox { handle, .. } => { + Self::CreateMailbox { handle, .. } => { handle.cancel(); } - JobRequest::DeleteMailbox { handle, .. } => { + Self::DeleteMailbox { handle, .. } => { handle.cancel(); } - JobRequest::Fetch { handle, .. } => { + Self::Fetch { handle, .. } => { handle.cancel(); } - JobRequest::Mailboxes { handle, .. } => { + Self::Mailboxes { handle, .. } => { handle.cancel(); } - JobRequest::SendMessage => {} + Self::SendMessage => {} } } } @@ -322,14 +322,14 @@ impl Drop for JobRequest { impl std::fmt::Debug for JobRequest { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - JobRequest::Generic { name, .. } => write!(f, "JobRequest::Generic({})", name), - JobRequest::Mailboxes { .. } => write!(f, "JobRequest::Mailboxes"), - JobRequest::Fetch { mailbox_hash, .. } => { + Self::Generic { name, .. } => write!(f, "JobRequest::Generic({})", name), + Self::Mailboxes { .. } => write!(f, "JobRequest::Mailboxes"), + Self::Fetch { mailbox_hash, .. } => { write!(f, "JobRequest::Fetch({})", mailbox_hash) } - JobRequest::IsOnline { .. } => write!(f, "JobRequest::IsOnline"), - JobRequest::Refresh { .. } => write!(f, "JobRequest::Refresh"), - JobRequest::SetFlags { + Self::IsOnline { .. } => write!(f, "JobRequest::IsOnline"), + Self::Refresh { .. } => write!(f, "JobRequest::Refresh"), + Self::SetFlags { env_hashes, mailbox_hash, flags, @@ -340,22 +340,22 @@ impl std::fmt::Debug for JobRequest { .field("mailbox_hash", &mailbox_hash) .field("flags", &flags) .finish(), - JobRequest::SaveMessage { .. } => write!(f, "JobRequest::SaveMessage"), - JobRequest::DeleteMessages { .. } => write!(f, "JobRequest::DeleteMessages"), - JobRequest::CreateMailbox { .. } => write!(f, "JobRequest::CreateMailbox"), - JobRequest::DeleteMailbox { mailbox_hash, .. } => { + Self::SaveMessage { .. } => write!(f, "JobRequest::SaveMessage"), + Self::DeleteMessages { .. } => write!(f, "JobRequest::DeleteMessages"), + Self::CreateMailbox { .. } => write!(f, "JobRequest::CreateMailbox"), + Self::DeleteMailbox { mailbox_hash, .. } => { write!(f, "JobRequest::DeleteMailbox({})", mailbox_hash) } //JobRequest::RenameMailbox, - JobRequest::SetMailboxPermissions { .. } => { + Self::SetMailboxPermissions { .. } => { write!(f, "JobRequest::SetMailboxPermissions") } - JobRequest::SetMailboxSubscription { .. } => { + Self::SetMailboxSubscription { .. } => { write!(f, "JobRequest::SetMailboxSubscription") } - JobRequest::Watch { .. } => write!(f, "JobRequest::Watch"), - JobRequest::SendMessage => write!(f, "JobRequest::SendMessage"), - JobRequest::SendMessageBackground { .. } => { + Self::Watch { .. } => write!(f, "JobRequest::Watch"), + Self::SendMessage => write!(f, "JobRequest::SendMessage"), + Self::SendMessageBackground { .. } => { write!(f, "JobRequest::SendMessageBackground") } } @@ -365,12 +365,12 @@ impl std::fmt::Debug for JobRequest { impl std::fmt::Display for JobRequest { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - JobRequest::Generic { name, .. } => write!(f, "{}", name), - JobRequest::Mailboxes { .. } => write!(f, "Get mailbox list"), - JobRequest::Fetch { .. } => write!(f, "Mailbox fetch"), - JobRequest::IsOnline { .. } => write!(f, "Online status check"), - JobRequest::Refresh { .. } => write!(f, "Refresh mailbox"), - JobRequest::SetFlags { + Self::Generic { name, .. } => write!(f, "{}", name), + Self::Mailboxes { .. } => write!(f, "Get mailbox list"), + Self::Fetch { .. } => write!(f, "Mailbox fetch"), + Self::IsOnline { .. } => write!(f, "Online status check"), + Self::Refresh { .. } => write!(f, "Refresh mailbox"), + Self::SetFlags { env_hashes, flags, .. } => write!( f, @@ -379,20 +379,20 @@ impl std::fmt::Display for JobRequest { if env_hashes.len() == 1 { "" } else { "s" }, flags ), - JobRequest::SaveMessage { .. } => write!(f, "Save message"), - JobRequest::DeleteMessages { env_hashes, .. } => write!( + Self::SaveMessage { .. } => write!(f, "Save message"), + Self::DeleteMessages { env_hashes, .. } => write!( f, "Delete {} message{}", env_hashes.len(), if env_hashes.len() == 1 { "" } else { "s" } ), - JobRequest::CreateMailbox { path, .. } => write!(f, "Create mailbox {}", path), - JobRequest::DeleteMailbox { .. } => write!(f, "Delete mailbox"), + Self::CreateMailbox { path, .. } => write!(f, "Create mailbox {}", path), + Self::DeleteMailbox { .. } => write!(f, "Delete mailbox"), //JobRequest::RenameMailbox, - JobRequest::SetMailboxPermissions { .. } => write!(f, "Set mailbox permissions"), - JobRequest::SetMailboxSubscription { .. } => write!(f, "Set mailbox subscription"), - JobRequest::Watch { .. } => write!(f, "Background watch"), - JobRequest::SendMessageBackground { .. } | JobRequest::SendMessage => { + Self::SetMailboxPermissions { .. } => write!(f, "Set mailbox permissions"), + Self::SetMailboxSubscription { .. } => write!(f, "Set mailbox subscription"), + Self::Watch { .. } => write!(f, "Background watch"), + Self::SendMessageBackground { .. } | Self::SendMessage => { write!(f, "Sending message") } } @@ -404,7 +404,7 @@ impl JobRequest { is_variant! { is_online, IsOnline { .. } } pub fn is_fetch(&self, mailbox_hash: MailboxHash) -> bool { - matches!(self, JobRequest::Fetch { + matches!(self, Self::Fetch { mailbox_hash: h, .. } if *h == mailbox_hash) } @@ -578,7 +578,7 @@ impl Account { } } - Ok(Account { + Ok(Self { hash, name, is_online: if !backend.capabilities().is_remote { @@ -1590,7 +1590,7 @@ impl Account { *retries *= 2; } Some(Duration::from_millis( - oldval * (4 * melib::utils::random::random_u8() as u64), + oldval * (4 * u64::from(melib::utils::random::random_u8())), )) } else { None @@ -2531,11 +2531,9 @@ fn build_mailboxes_order( .collect::>() .into_iter() .peekable(); + indentation <<= 1; if has_sibling { - indentation <<= 1; indentation |= 1; - } else { - indentation <<= 1; } while let Some(i) = iter.next() { let c = &mut node.children[i]; diff --git a/meli/src/accounts/backend_ops.rs b/meli/src/accounts/backend_ops.rs index 091f7b05..a29a45e0 100644 --- a/meli/src/accounts/backend_ops.rs +++ b/meli/src/accounts/backend_ops.rs @@ -60,7 +60,7 @@ impl Account { pub(super) fn update_cached_env(&mut self, env: Envelope, old_hash: Option) { if self.settings.conf.search_backend == crate::conf::SearchBackend::Sqlite3 { let msg_id = env.message_id_display().to_string(); - match crate::sqlite3::remove(old_hash.unwrap_or(env.hash())) + match crate::sqlite3::remove(old_hash.unwrap_or_else(|| env.hash())) .map(|_| crate::sqlite3::insert(env, self.backend.clone(), self.name.clone())) { Ok(job) => { diff --git a/meli/src/args.rs b/meli/src/args.rs index f9771f0b..8ee71509 100644 --- a/meli/src/args.rs +++ b/meli/src/args.rs @@ -179,10 +179,10 @@ pub mod manpages { }; for (p, dir) in [ - (ManPages::Main, "man1"), - (ManPages::Conf, "man5"), - (ManPages::Themes, "man5"), - (ManPages::Guide, "man7"), + (Self::Main, "man1"), + (Self::Conf, "man5"), + (Self::Themes, "man5"), + (Self::Guide, "man7"), ] { let text = crate::subcommands::man(p, true)?; path.push(dir); diff --git a/meli/src/command.rs b/meli/src/command.rs index b4e22199..e30c6d1c 100644 --- a/meli/src/command.rs +++ b/meli/src/command.rs @@ -503,7 +503,7 @@ Alternatives(&[to_stream!(One(Literal("add-attachment")), One(Filepath)), to_str /// Get command suggestions for input pub fn command_completion_suggestions(input: &str) -> Vec { use crate::melib::ShellExpandTrait; - let mut sugg = Default::default(); + let mut sugg: HashSet = Default::default(); for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() { let _m = tokens.matches(&mut &(*input), &mut sugg); if _m.is_empty() { @@ -528,17 +528,15 @@ mod tests { let mut input = "sort".to_string(); macro_rules! match_input { ($input:expr) => {{ - let mut sugg = Default::default(); - let mut vec = vec![]; + let mut sugg: HashSet = Default::default(); //print!("{}", $input); for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() { - //println!("{:?}, {:?}, {:?}", _tags, _desc, tokens); - let m = tokens.matches(&mut $input.as_str(), &mut sugg); - if !m.is_empty() { - vec.push(tokens); - //print!("{:?} ", desc); - //println!(" result = {:#?}\n\n", m); - } + // //println!("{:?}, {:?}, {:?}", _tags, _desc, tokens); + let _ = tokens.matches(&mut $input.as_str(), &mut sugg); + // if !m.is_empty() { + // //print!("{:?} ", desc); + // //println!(" result = {:#?}\n\n", m); + // } } //println!("suggestions = {:#?}", sugg); sugg.into_iter() @@ -587,7 +585,7 @@ mod tests { match io::stdin().read_line(&mut input) { Ok(_n) => { println!("Input is {:?}", input.as_str().trim()); - let mut sugg = Default::default(); + let mut sugg: HashSet = Default::default(); let mut vec = vec![]; //print!("{}", input); for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() { diff --git a/meli/src/command/actions.rs b/meli/src/command/actions.rs index a8f93753..12fcc560 100644 --- a/meli/src/command/actions.rs +++ b/meli/src/command/actions.rs @@ -143,10 +143,10 @@ impl Action { pub fn needs_confirmation(&self) -> bool { matches!( self, - Action::Listing(ListingAction::Delete) - | Action::MailingListAction(_) - | Action::Mailbox(_, _) - | Action::Quit + Self::Listing(ListingAction::Delete) + | Self::MailingListAction(_) + | Self::Mailbox(_, _) + | Self::Quit ) } } diff --git a/meli/src/conf.rs b/meli/src/conf.rs index 2c0b760d..ec81a2e8 100644 --- a/meli/src/conf.rs +++ b/meli/src/conf.rs @@ -279,7 +279,7 @@ impl From for AccountConf { }; let mailbox_confs = x.mailboxes.clone(); - AccountConf { + Self { account: acc, conf_override: x.conf_override.clone(), conf: x, @@ -393,7 +393,7 @@ define(`include', `builtin_include(substr($1,1,decr(decr(len($1)))))dnl')dnl file.read_to_string(&mut contents)?; let mut handle = Command::new("m4") - .current_dir(conf_path.parent().unwrap_or(Path::new("/"))) + .current_dir(conf_path.parent().unwrap_or_else(|| Path::new("/"))) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) @@ -407,7 +407,7 @@ define(`include', `builtin_include(substr($1,1,decr(decr(len($1)))))dnl')dnl } impl FileSettings { - pub fn new() -> Result { + pub fn new() -> Result { let config_path = get_config_file()?; if !config_path.exists() { let path_string = config_path.display().to_string(); @@ -429,12 +429,12 @@ impl FileSettings { )); } #[cfg(test)] - return Ok(FileSettings::default()); + return Ok(Self::default()); #[cfg(not(test))] return Err(Error::new("No configuration file found.")); } - FileSettings::validate(config_path, true, false) + Self::validate(config_path, true, false) } pub fn validate(path: PathBuf, interactive: bool, clear_extras: bool) -> Result { @@ -467,11 +467,11 @@ This is required so that you don't accidentally start meli and find out later th }; if ask.run() { let mut file = OpenOptions::new().append(true).open(&path)?; - file.write_all("[composing]\nsend_mail = 'false'\n".as_bytes()) + file.write_all(b"[composing]\nsend_mail = 'false'\n") .map_err(|err| { Error::new(format!("Could not append to {}: {}", path.display(), err)) })?; - return FileSettings::validate(path, interactive, clear_extras); + return Self::validate(path, interactive, clear_extras); } } return Err(Error::new(format!( @@ -480,7 +480,7 @@ This is required so that you don't accidentally start meli and find out later th path.display() ))); } - let mut s: FileSettings = toml::from_str(&s).map_err(|err| { + let mut s: Self = toml::from_str(&s).map_err(|err| { Error::new(format!( "{}: Config file contains errors; {}", path.display(), @@ -588,7 +588,7 @@ pub struct Settings { } impl Settings { - pub fn new() -> Result { + pub fn new() -> Result { let fs = FileSettings::new()?; let mut s: IndexMap = IndexMap::new(); @@ -605,7 +605,7 @@ impl Settings { _logger.change_log_dest(log_path.into()); } - Ok(Settings { + Ok(Self { accounts: s, pager: fs.pager, listing: fs.listing, @@ -620,7 +620,7 @@ impl Settings { }) } - pub fn without_accounts() -> Result { + pub fn without_accounts() -> Result { let fs = FileSettings::new()?; let mut _logger = StderrLogger::new(fs.log.maximum_level); @@ -628,7 +628,7 @@ impl Settings { _logger.change_log_dest(log_path.into()); } - Ok(Settings { + Ok(Self { accounts: IndexMap::new(), pager: fs.pager, listing: fs.listing, @@ -761,10 +761,10 @@ impl<'de> Deserialize<'de> for IndexStyle { { let s = ::deserialize(deserializer)?; match s.as_str() { - "Plain" | "plain" => Ok(IndexStyle::Plain), - "Threaded" | "threaded" => Ok(IndexStyle::Threaded), - "Compact" | "compact" => Ok(IndexStyle::Compact), - "Conversations" | "conversations" => Ok(IndexStyle::Conversations), + "Plain" | "plain" => Ok(Self::Plain), + "Threaded" | "threaded" => Ok(Self::Threaded), + "Compact" | "compact" => Ok(Self::Compact), + "Conversations" | "conversations" => Ok(Self::Conversations), _ => Err(de::Error::custom("invalid `index_style` value")), } } @@ -776,10 +776,10 @@ impl Serialize for IndexStyle { S: Serializer, { match self { - IndexStyle::Plain => serializer.serialize_str("plain"), - IndexStyle::Threaded => serializer.serialize_str("threaded"), - IndexStyle::Compact => serializer.serialize_str("compact"), - IndexStyle::Conversations => serializer.serialize_str("conversations"), + Self::Plain => serializer.serialize_str("plain"), + Self::Threaded => serializer.serialize_str("threaded"), + Self::Compact => serializer.serialize_str("compact"), + Self::Conversations => serializer.serialize_str("conversations"), } } } @@ -805,15 +805,15 @@ impl<'de> Deserialize<'de> for SearchBackend { if sqlite3.eq_ignore_ascii_case("sqlite3") || sqlite3.eq_ignore_ascii_case("sqlite") => { - Ok(SearchBackend::Sqlite3) + Ok(Self::Sqlite3) } none if none.eq_ignore_ascii_case("none") || none.eq_ignore_ascii_case("nothing") || none.is_empty() => { - Ok(SearchBackend::None) + Ok(Self::None) } - auto if auto.eq_ignore_ascii_case("auto") => Ok(SearchBackend::Auto), + auto if auto.eq_ignore_ascii_case("auto") => Ok(Self::Auto), _ => Err(de::Error::custom("invalid `search_backend` value")), } } @@ -826,9 +826,9 @@ impl Serialize for SearchBackend { { match self { #[cfg(feature = "sqlite3")] - SearchBackend::Sqlite3 => serializer.serialize_str("sqlite3"), - SearchBackend::None => serializer.serialize_str("none"), - SearchBackend::Auto => serializer.serialize_str("auto"), + Self::Sqlite3 => serializer.serialize_str("sqlite3"), + Self::None => serializer.serialize_str("none"), + Self::Auto => serializer.serialize_str("auto"), } } } @@ -1332,7 +1332,7 @@ send_mail = 'false' .append(true) .open(&path)?; file.write_all(content.as_bytes())?; - Ok(ConfigFile { path, file }) + Ok(Self { path, file }) } } @@ -1350,7 +1350,7 @@ send_mail = 'false' )); new_file .file - .write_all("[composing]\nsend_mail = 'false'\n".as_bytes()) + .write_all(b"[composing]\nsend_mail = 'false'\n") .unwrap(); let err = FileSettings::validate(new_file.path.clone(), false, true).unwrap_err(); assert_eq!( diff --git a/meli/src/conf/composing.rs b/meli/src/conf/composing.rs index e324257a..1ebd082d 100644 --- a/meli/src/conf/composing.rs +++ b/meli/src/conf/composing.rs @@ -115,7 +115,7 @@ pub struct ComposingSettings { impl Default for ComposingSettings { fn default() -> Self { - ComposingSettings { + Self { send_mail: SendMail::ShellCommand("false".into()), editor_command: None, embedded_pty: false, @@ -296,9 +296,9 @@ impl<'de> Deserialize<'de> for SendMail { match ::deserialize(deserializer) { #[cfg(feature = "smtp")] - Ok(SendMailInner::Smtp(v)) => Ok(SendMail::Smtp(v)), - Ok(SendMailInner::ServerSubmission) => Ok(SendMail::ServerSubmission), - Ok(SendMailInner::ShellCommand(v)) => Ok(SendMail::ShellCommand(v)), + Ok(SendMailInner::Smtp(v)) => Ok(Self::Smtp(v)), + Ok(SendMailInner::ServerSubmission) => Ok(Self::ServerSubmission), + Ok(SendMailInner::ShellCommand(v)) => Ok(Self::ShellCommand(v)), Err(_err) => Err(de::Error::custom(SENDMAIL_ERR_HELP)), } } diff --git a/meli/src/conf/overrides.rs b/meli/src/conf/overrides.rs index 6ffad9f7..8453c61a 100644 --- a/meli/src/conf/overrides.rs +++ b/meli/src/conf/overrides.rs @@ -27,17 +27,17 @@ use super::*; use melib::HeaderName; -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PagerSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "pager-context")] # [serde (default)] pub pager_context : Option < usize > , # [doc = " Stop at the end instead of displaying next mail."] # [doc = " Default: false"] # [serde (alias = "pager-stop")] # [serde (default)] pub pager_stop : Option < bool > , # [doc = " Always show headers when scrolling."] # [doc = " Default: true"] # [serde (alias = "sticky-headers" , alias = "headers-sticky" , alias = "headers_sticky")] # [serde (default)] pub sticky_headers : Option < bool > , # [doc = " The height of the pager in mail view, in percent."] # [doc = " Default: 80"] # [serde (alias = "pager-ratio")] # [serde (default)] pub pager_ratio : Option < usize > , # [doc = " A command to pipe mail output through for viewing in pager."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub filter : Option < Option < String > > , # [doc = " A command to pipe html output before displaying it in a pager"] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-filter")] # [serde (default)] pub html_filter : Option < Option < String > > , # [doc = " Respect \"format=flowed\""] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Split long lines that would overflow on the x axis."] # [doc = " Default: true"] # [serde (alias = "split-long-lines")] # [serde (default)] pub split_long_lines : Option < bool > , # [doc = " Minimum text width in columns."] # [doc = " Default: 80"] # [serde (alias = "minimum-width")] # [serde (default)] pub minimum_width : Option < usize > , # [doc = " Choose `text/html` alternative if `text/plain` is empty in"] # [doc = " `multipart/alternative` attachments."] # [doc = " Default: true"] # [serde (alias = "auto-choose-multipart-alternative")] # [serde (default)] pub auto_choose_multipart_alternative : Option < ToggleFlag > , # [doc = " Show Date: in my timezone"] # [doc = " Default: true"] # [serde (alias = "show-date-in-my-timezone")] # [serde (default)] pub show_date_in_my_timezone : Option < ToggleFlag > , # [doc = " A command to launch URLs with. The URL will be given as the first"] # [doc = " argument of the command. Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub url_launcher : Option < Option < String > > , # [doc = " A command to open html files."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-open")] # [serde (default)] pub html_open : Option < Option < String > > , # [doc = " Extra headers to display, if present, in the default header preamble."] # [doc = " Default: []"] # [serde (alias = "show-extra-headers")] # [serde (default)] pub show_extra_headers : Option < Vec < String > > } impl Default for PagerSettingsOverride { fn default () -> Self { PagerSettingsOverride { pager_context : None , pager_stop : None , sticky_headers : None , pager_ratio : None , filter : None , html_filter : None , format_flowed : None , split_long_lines : None , minimum_width : None , auto_choose_multipart_alternative : None , show_date_in_my_timezone : None , url_launcher : None , html_open : None , show_extra_headers : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PagerSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "pager-context")] # [serde (default)] pub pager_context : Option < usize > , # [doc = " Stop at the end instead of displaying next mail."] # [doc = " Default: false"] # [serde (alias = "pager-stop")] # [serde (default)] pub pager_stop : Option < bool > , # [doc = " Always show headers when scrolling."] # [doc = " Default: true"] # [serde (alias = "sticky-headers" , alias = "headers-sticky" , alias = "headers_sticky")] # [serde (default)] pub sticky_headers : Option < bool > , # [doc = " The height of the pager in mail view, in percent."] # [doc = " Default: 80"] # [serde (alias = "pager-ratio")] # [serde (default)] pub pager_ratio : Option < usize > , # [doc = " A command to pipe mail output through for viewing in pager."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub filter : Option < Option < String > > , # [doc = " A command to pipe html output before displaying it in a pager"] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-filter")] # [serde (default)] pub html_filter : Option < Option < String > > , # [doc = " Respect \"format=flowed\""] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Split long lines that would overflow on the x axis."] # [doc = " Default: true"] # [serde (alias = "split-long-lines")] # [serde (default)] pub split_long_lines : Option < bool > , # [doc = " Minimum text width in columns."] # [doc = " Default: 80"] # [serde (alias = "minimum-width")] # [serde (default)] pub minimum_width : Option < usize > , # [doc = " Choose `text/html` alternative if `text/plain` is empty in"] # [doc = " `multipart/alternative` attachments."] # [doc = " Default: true"] # [serde (alias = "auto-choose-multipart-alternative")] # [serde (default)] pub auto_choose_multipart_alternative : Option < ToggleFlag > , # [doc = " Show Date: in my timezone"] # [doc = " Default: true"] # [serde (alias = "show-date-in-my-timezone")] # [serde (default)] pub show_date_in_my_timezone : Option < ToggleFlag > , # [doc = " A command to launch URLs with. The URL will be given as the first"] # [doc = " argument of the command. Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub url_launcher : Option < Option < String > > , # [doc = " A command to open html files."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-open")] # [serde (default)] pub html_open : Option < Option < String > > , # [doc = " Extra headers to display, if present, in the default header preamble."] # [doc = " Default: []"] # [serde (alias = "show-extra-headers")] # [serde (default)] pub show_extra_headers : Option < Vec < String > > } impl Default for PagerSettingsOverride { fn default () -> Self { Self { pager_context : None , pager_stop : None , sticky_headers : None , pager_ratio : None , filter : None , html_filter : None , format_flowed : None , split_long_lines : None , minimum_width : None , auto_choose_multipart_alternative : None , show_date_in_my_timezone : None , url_launcher : None , html_open : None , show_extra_headers : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ListingSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "context-lines")] # [serde (default)] pub context_lines : Option < usize > , # [doc = " Show auto-hiding scrollbar in accounts sidebar menu."] # [doc = " Default: True"] # [serde (default)] pub show_menu_scrollbar : Option < bool > , # [doc = " Datetime formatting passed verbatim to strftime(3)."] # [doc = " Default: %Y-%m-%d %T"] # [serde (alias = "datetime-fmt")] # [serde (default)] pub datetime_fmt : Option < Option < String > > , # [doc = " Show recent dates as `X {minutes,hours,days} ago`, up to 7 days."] # [doc = " Default: true"] # [serde (alias = "recent-dates")] # [serde (default)] pub recent_dates : Option < bool > , # [doc = " Show only envelopes that match this query"] # [doc = " Default: None"] # [serde (default)] pub filter : Option < Option < Query > > , # [serde (alias = "index-style")] # [serde (default)] pub index_style : Option < IndexStyle > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling_leaf : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling_leaf : Option < Option < String > > , # [doc = " Default: ' '"] # [serde (default)] pub sidebar_divider : Option < char > , # [doc = " Default: 90"] # [serde (default)] pub sidebar_ratio : Option < usize > , # [doc = " Flag to show if thread entry contains unseen mail."] # [doc = " Default: \"●\""] # [serde (default)] pub unseen_flag : Option < Option < String > > , # [doc = " Flag to show if thread has been snoozed."] # [doc = " Default: \"💤\""] # [serde (default)] pub thread_snoozed_flag : Option < Option < String > > , # [doc = " Flag to show if thread entry has been selected."] # [doc = " Default: \"☑\u{fe0f}\""] # [serde (default)] pub selected_flag : Option < Option < String > > , # [doc = " Flag to show if thread entry contains attachments."] # [doc = " Default: \"📎\""] # [serde (default)] pub attachment_flag : Option < Option < String > > , # [doc = " Should threads with different Subjects show a list of those"] # [doc = " subjects on the entry title?"] # [doc = " Default: \"true\""] # [serde (default)] pub thread_subject_pack : Option < bool > , # [doc = " In threaded listing style, repeat identical From column values within a"] # [doc = " thread. Not repeating adds empty space in the From column which"] # [doc = " might result in less visual clutter."] # [doc = " Default: \"false\""] # [serde (default)] pub threaded_repeat_identical_from_values : Option < bool > , # [doc = " Show relative indices in menu mailboxes to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-menu-indices")] # [serde (default)] pub relative_menu_indices : Option < bool > , # [doc = " Show relative indices in listings to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-list-indices")] # [serde (default)] pub relative_list_indices : Option < bool > , # [doc = " Hide sidebar on launch. Default: \"false\""] # [serde (alias = "hide-sidebar-on-launch")] # [serde (default)] pub hide_sidebar_on_launch : Option < bool > } impl Default for ListingSettingsOverride { fn default () -> Self { ListingSettingsOverride { context_lines : None , show_menu_scrollbar : None , datetime_fmt : None , recent_dates : None , filter : None , index_style : None , sidebar_mailbox_tree_has_sibling : None , sidebar_mailbox_tree_no_sibling : None , sidebar_mailbox_tree_has_sibling_leaf : None , sidebar_mailbox_tree_no_sibling_leaf : None , sidebar_divider : None , sidebar_ratio : None , unseen_flag : None , thread_snoozed_flag : None , selected_flag : None , attachment_flag : None , thread_subject_pack : None , threaded_repeat_identical_from_values : None , relative_menu_indices : None , relative_list_indices : None , hide_sidebar_on_launch : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ListingSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "context-lines")] # [serde (default)] pub context_lines : Option < usize > , # [doc = " Show auto-hiding scrollbar in accounts sidebar menu."] # [doc = " Default: True"] # [serde (default)] pub show_menu_scrollbar : Option < bool > , # [doc = " Datetime formatting passed verbatim to strftime(3)."] # [doc = " Default: %Y-%m-%d %T"] # [serde (alias = "datetime-fmt")] # [serde (default)] pub datetime_fmt : Option < Option < String > > , # [doc = " Show recent dates as `X {minutes,hours,days} ago`, up to 7 days."] # [doc = " Default: true"] # [serde (alias = "recent-dates")] # [serde (default)] pub recent_dates : Option < bool > , # [doc = " Show only envelopes that match this query"] # [doc = " Default: None"] # [serde (default)] pub filter : Option < Option < Query > > , # [serde (alias = "index-style")] # [serde (default)] pub index_style : Option < IndexStyle > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling_leaf : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling_leaf : Option < Option < String > > , # [doc = " Default: ' '"] # [serde (default)] pub sidebar_divider : Option < char > , # [doc = " Default: 90"] # [serde (default)] pub sidebar_ratio : Option < usize > , # [doc = " Flag to show if thread entry contains unseen mail."] # [doc = " Default: \"●\""] # [serde (default)] pub unseen_flag : Option < Option < String > > , # [doc = " Flag to show if thread has been snoozed."] # [doc = " Default: \"💤\""] # [serde (default)] pub thread_snoozed_flag : Option < Option < String > > , # [doc = " Flag to show if thread entry has been selected."] # [doc = " Default: \"☑\u{fe0f}\""] # [serde (default)] pub selected_flag : Option < Option < String > > , # [doc = " Flag to show if thread entry contains attachments."] # [doc = " Default: \"📎\""] # [serde (default)] pub attachment_flag : Option < Option < String > > , # [doc = " Should threads with different Subjects show a list of those"] # [doc = " subjects on the entry title?"] # [doc = " Default: \"true\""] # [serde (default)] pub thread_subject_pack : Option < bool > , # [doc = " In threaded listing style, repeat identical From column values within a"] # [doc = " thread. Not repeating adds empty space in the From column which"] # [doc = " might result in less visual clutter."] # [doc = " Default: \"false\""] # [serde (default)] pub threaded_repeat_identical_from_values : Option < bool > , # [doc = " Show relative indices in menu mailboxes to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-menu-indices")] # [serde (default)] pub relative_menu_indices : Option < bool > , # [doc = " Show relative indices in listings to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-list-indices")] # [serde (default)] pub relative_list_indices : Option < bool > , # [doc = " Hide sidebar on launch. Default: \"false\""] # [serde (alias = "hide-sidebar-on-launch")] # [serde (default)] pub hide_sidebar_on_launch : Option < bool > } impl Default for ListingSettingsOverride { fn default () -> Self { Self { context_lines : None , show_menu_scrollbar : None , datetime_fmt : None , recent_dates : None , filter : None , index_style : None , sidebar_mailbox_tree_has_sibling : None , sidebar_mailbox_tree_no_sibling : None , sidebar_mailbox_tree_has_sibling_leaf : None , sidebar_mailbox_tree_no_sibling_leaf : None , sidebar_divider : None , sidebar_ratio : None , unseen_flag : None , thread_snoozed_flag : None , selected_flag : None , attachment_flag : None , thread_subject_pack : None , threaded_repeat_identical_from_values : None , relative_menu_indices : None , relative_list_indices : None , hide_sidebar_on_launch : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct NotificationsSettingsOverride { # [doc = " Enable notifications."] # [doc = " Default: True"] # [serde (default)] pub enable : Option < bool > , # [doc = " A command to pipe notifications through."] # [doc = " Default: None"] # [serde (default)] pub script : Option < Option < String > > , # [doc = " A command to pipe new mail notifications through (preferred over"] # [doc = " `script`). Default: None"] # [serde (default)] pub new_mail_script : Option < Option < String > > , # [doc = " A file location which has its size changed when new mail arrives (max"] # [doc = " 128 bytes). Can be used to trigger new mail notifications eg with"] # [doc = " `xbiff(1)`. Default: None"] # [serde (alias = "xbiff-file-path")] # [serde (default)] pub xbiff_file_path : Option < Option < String > > , # [serde (alias = "play-sound")] # [serde (default)] pub play_sound : Option < ToggleFlag > , # [serde (alias = "sound-file")] # [serde (default)] pub sound_file : Option < Option < String > > } impl Default for NotificationsSettingsOverride { fn default () -> Self { NotificationsSettingsOverride { enable : None , script : None , new_mail_script : None , xbiff_file_path : None , play_sound : None , sound_file : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct NotificationsSettingsOverride { # [doc = " Enable notifications."] # [doc = " Default: True"] # [serde (default)] pub enable : Option < bool > , # [doc = " A command to pipe notifications through."] # [doc = " Default: None"] # [serde (default)] pub script : Option < Option < String > > , # [doc = " A command to pipe new mail notifications through (preferred over"] # [doc = " `script`). Default: None"] # [serde (default)] pub new_mail_script : Option < Option < String > > , # [doc = " A file location which has its size changed when new mail arrives (max"] # [doc = " 128 bytes). Can be used to trigger new mail notifications eg with"] # [doc = " `xbiff(1)`. Default: None"] # [serde (alias = "xbiff-file-path")] # [serde (default)] pub xbiff_file_path : Option < Option < String > > , # [serde (alias = "play-sound")] # [serde (default)] pub play_sound : Option < ToggleFlag > , # [serde (alias = "sound-file")] # [serde (default)] pub sound_file : Option < Option < String > > } impl Default for NotificationsSettingsOverride { fn default () -> Self { Self { enable : None , script : None , new_mail_script : None , xbiff_file_path : None , play_sound : None , sound_file : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ShortcutsOverride { # [serde (default)] pub general : Option < GeneralShortcuts > , # [serde (default)] pub listing : Option < ListingShortcuts > , # [serde (default)] pub composing : Option < ComposingShortcuts > , # [serde (alias = "contact-list")] # [serde (default)] pub contact_list : Option < ContactListShortcuts > , # [serde (alias = "envelope-view")] # [serde (default)] pub envelope_view : Option < EnvelopeViewShortcuts > , # [serde (alias = "thread-view")] # [serde (default)] pub thread_view : Option < ThreadViewShortcuts > , # [serde (default)] pub pager : Option < PagerShortcuts > } impl Default for ShortcutsOverride { fn default () -> Self { ShortcutsOverride { general : None , listing : None , composing : None , contact_list : None , envelope_view : None , thread_view : None , pager : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ShortcutsOverride { # [serde (default)] pub general : Option < GeneralShortcuts > , # [serde (default)] pub listing : Option < ListingShortcuts > , # [serde (default)] pub composing : Option < ComposingShortcuts > , # [serde (alias = "contact-list")] # [serde (default)] pub contact_list : Option < ContactListShortcuts > , # [serde (alias = "envelope-view")] # [serde (default)] pub envelope_view : Option < EnvelopeViewShortcuts > , # [serde (alias = "thread-view")] # [serde (default)] pub thread_view : Option < ThreadViewShortcuts > , # [serde (default)] pub pager : Option < PagerShortcuts > } impl Default for ShortcutsOverride { fn default () -> Self { Self { general : None , listing : None , composing : None , contact_list : None , envelope_view : None , thread_view : None , pager : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ComposingSettingsOverride { # [doc = " A command to pipe new emails to"] # [doc = " Required"] # [serde (default)] pub send_mail : Option < SendMail > , # [doc = " Command to launch editor. Can have arguments. Draft filename is given as"] # [doc = " the last argument. If it's missing, the environment variable $EDITOR is"] # [doc = " looked up."] # [serde (alias = "editor-command" , alias = "editor-cmd" , alias = "editor_cmd")] # [serde (default)] pub editor_command : Option < Option < String > > , # [doc = " Embedded editor (for terminal interfaces) instead of forking and"] # [doc = " waiting."] # [serde (alias = "embed")] # [serde (default)] pub embedded_pty : Option < bool > , # [doc = " Set \"format=flowed\" in plain text attachments."] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Set User-Agent"] # [doc = " Default: empty"] # [serde (alias = "insert_user_agent")] # [serde (default)] pub insert_user_agent : Option < bool > , # [doc = " Set default header values for new drafts"] # [doc = " Default: empty"] # [serde (alias = "default-header-values")] # [serde (default)] pub default_header_values : Option < HashMap < HeaderName , String > > , # [doc = " Wrap header preample when editing a draft in an editor. This allows you"] # [doc = " to write non-plain text email without the preamble creating syntax"] # [doc = " errors. They are stripped when you return from the editor. The"] # [doc = " values should be a two element array of strings, a prefix and suffix."] # [doc = " Default: None"] # [serde (alias = "wrap-header-preample")] # [serde (default)] pub wrap_header_preamble : Option < Option < (String , String) > > , # [doc = " Store sent mail after successful submission. This setting is meant to be"] # [doc = " disabled for non-standard behaviour in gmail, which auto-saves sent"] # [doc = " mail on its own. Default: true"] # [serde (default)] pub store_sent_mail : Option < bool > , # [doc = " The attribution line appears above the quoted reply text."] # [doc = " The format specifiers for the replied address are:"] # [doc = " - `%+f` — the sender's name and email address."] # [doc = " - `%+n` — the sender's name (or email address, if no name is included)."] # [doc = " - `%+a` — the sender's email address."] # [doc = " The format string is passed to strftime(3) with the replied envelope's"] # [doc = " date. Default: \"On %a, %0e %b %Y %H:%M, %+f wrote:%n\""] # [serde (default)] pub attribution_format_string : Option < Option < String > > , # [doc = " Whether the strftime call for the attribution string uses the POSIX"] # [doc = " locale instead of the user's active locale"] # [doc = " Default: true"] # [serde (default)] pub attribution_use_posix_locale : Option < bool > , # [doc = " Forward emails as attachment? (Alternative is inline)"] # [doc = " Default: ask"] # [serde (alias = "forward-as-attachment")] # [serde (default)] pub forward_as_attachment : Option < ToggleFlag > , # [doc = " Alternative lists of reply prefixes (etc. [\"Re:\", \"RE:\", ...]) to strip"] # [doc = " Default: `[\"Re:\", \"RE:\", \"Fwd:\", \"Fw:\", \"回复:\", \"回覆:\", \"SV:\", \"Sv:\","] # [doc = " \"VS:\", \"Antw:\", \"Doorst:\", \"VS:\", \"VL:\", \"REF:\", \"TR:\", \"TR:\", \"AW:\","] # [doc = " \"WG:\", \"ΑΠ:\", \"Απ:\", \"απ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"ΣΧΕΤ:\", \"Σχετ:\","] # [doc = " \"σχετ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"Vá:\", \"Továbbítás:\", \"R:\", \"I:\","] # [doc = " \"RIF:\", \"FS:\", \"BLS:\", \"TRS:\", \"VS:\", \"VB:\", \"RV:\", \"RES:\", \"Res\","] # [doc = " \"ENC:\", \"Odp:\", \"PD:\", \"YNT:\", \"İLT:\", \"ATB:\", \"YML:\"]`"] # [serde (alias = "reply-prefix-list-to-strip")] # [serde (default)] pub reply_prefix_list_to_strip : Option < Option < Vec < String > > > , # [doc = " The prefix to use in reply subjects. The de facto prefix is \"Re:\"."] # [serde (alias = "reply-prefix")] # [serde (default)] pub reply_prefix : Option < String > , # [doc = " Custom `compose-hooks`."] # [serde (alias = "custom-compose-hooks")] # [serde (default)] pub custom_compose_hooks : Option < Vec < ComposeHook > > , # [doc = " Disabled `compose-hooks`."] # [serde (alias = "disabled-compose-hooks")] # [serde (default)] pub disabled_compose_hooks : Option < Vec < String > > } impl Default for ComposingSettingsOverride { fn default () -> Self { ComposingSettingsOverride { send_mail : None , editor_command : None , embedded_pty : None , format_flowed : None , insert_user_agent : None , default_header_values : None , wrap_header_preamble : None , store_sent_mail : None , attribution_format_string : None , attribution_use_posix_locale : None , forward_as_attachment : None , reply_prefix_list_to_strip : None , reply_prefix : None , custom_compose_hooks : None , disabled_compose_hooks : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ComposingSettingsOverride { # [doc = " A command to pipe new emails to"] # [doc = " Required"] # [serde (default)] pub send_mail : Option < SendMail > , # [doc = " Command to launch editor. Can have arguments. Draft filename is given as"] # [doc = " the last argument. If it's missing, the environment variable $EDITOR is"] # [doc = " looked up."] # [serde (alias = "editor-command" , alias = "editor-cmd" , alias = "editor_cmd")] # [serde (default)] pub editor_command : Option < Option < String > > , # [doc = " Embedded editor (for terminal interfaces) instead of forking and"] # [doc = " waiting."] # [serde (alias = "embed")] # [serde (default)] pub embedded_pty : Option < bool > , # [doc = " Set \"format=flowed\" in plain text attachments."] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Set User-Agent"] # [doc = " Default: empty"] # [serde (alias = "insert_user_agent")] # [serde (default)] pub insert_user_agent : Option < bool > , # [doc = " Set default header values for new drafts"] # [doc = " Default: empty"] # [serde (alias = "default-header-values")] # [serde (default)] pub default_header_values : Option < HashMap < HeaderName , String > > , # [doc = " Wrap header preample when editing a draft in an editor. This allows you"] # [doc = " to write non-plain text email without the preamble creating syntax"] # [doc = " errors. They are stripped when you return from the editor. The"] # [doc = " values should be a two element array of strings, a prefix and suffix."] # [doc = " Default: None"] # [serde (alias = "wrap-header-preample")] # [serde (default)] pub wrap_header_preamble : Option < Option < (String , String) > > , # [doc = " Store sent mail after successful submission. This setting is meant to be"] # [doc = " disabled for non-standard behaviour in gmail, which auto-saves sent"] # [doc = " mail on its own. Default: true"] # [serde (default)] pub store_sent_mail : Option < bool > , # [doc = " The attribution line appears above the quoted reply text."] # [doc = " The format specifiers for the replied address are:"] # [doc = " - `%+f` — the sender's name and email address."] # [doc = " - `%+n` — the sender's name (or email address, if no name is included)."] # [doc = " - `%+a` — the sender's email address."] # [doc = " The format string is passed to strftime(3) with the replied envelope's"] # [doc = " date. Default: \"On %a, %0e %b %Y %H:%M, %+f wrote:%n\""] # [serde (default)] pub attribution_format_string : Option < Option < String > > , # [doc = " Whether the strftime call for the attribution string uses the POSIX"] # [doc = " locale instead of the user's active locale"] # [doc = " Default: true"] # [serde (default)] pub attribution_use_posix_locale : Option < bool > , # [doc = " Forward emails as attachment? (Alternative is inline)"] # [doc = " Default: ask"] # [serde (alias = "forward-as-attachment")] # [serde (default)] pub forward_as_attachment : Option < ToggleFlag > , # [doc = " Alternative lists of reply prefixes (etc. [\"Re:\", \"RE:\", ...]) to strip"] # [doc = " Default: `[\"Re:\", \"RE:\", \"Fwd:\", \"Fw:\", \"回复:\", \"回覆:\", \"SV:\", \"Sv:\","] # [doc = " \"VS:\", \"Antw:\", \"Doorst:\", \"VS:\", \"VL:\", \"REF:\", \"TR:\", \"TR:\", \"AW:\","] # [doc = " \"WG:\", \"ΑΠ:\", \"Απ:\", \"απ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"ΣΧΕΤ:\", \"Σχετ:\","] # [doc = " \"σχετ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"Vá:\", \"Továbbítás:\", \"R:\", \"I:\","] # [doc = " \"RIF:\", \"FS:\", \"BLS:\", \"TRS:\", \"VS:\", \"VB:\", \"RV:\", \"RES:\", \"Res\","] # [doc = " \"ENC:\", \"Odp:\", \"PD:\", \"YNT:\", \"İLT:\", \"ATB:\", \"YML:\"]`"] # [serde (alias = "reply-prefix-list-to-strip")] # [serde (default)] pub reply_prefix_list_to_strip : Option < Option < Vec < String > > > , # [doc = " The prefix to use in reply subjects. The de facto prefix is \"Re:\"."] # [serde (alias = "reply-prefix")] # [serde (default)] pub reply_prefix : Option < String > , # [doc = " Custom `compose-hooks`."] # [serde (alias = "custom-compose-hooks")] # [serde (default)] pub custom_compose_hooks : Option < Vec < ComposeHook > > , # [doc = " Disabled `compose-hooks`."] # [serde (alias = "disabled-compose-hooks")] # [serde (default)] pub disabled_compose_hooks : Option < Vec < String > > } impl Default for ComposingSettingsOverride { fn default () -> Self { Self { send_mail : None , editor_command : None , embedded_pty : None , format_flowed : None , insert_user_agent : None , default_header_values : None , wrap_header_preamble : None , store_sent_mail : None , attribution_format_string : None , attribution_use_posix_locale : None , forward_as_attachment : None , reply_prefix_list_to_strip : None , reply_prefix : None , custom_compose_hooks : None , disabled_compose_hooks : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct TagsSettingsOverride { # [serde (deserialize_with = "tag_color_de")] # [serde (default)] pub colors : Option < HashMap < TagHash , Color > > , # [serde (deserialize_with = "tag_set_de" , alias = "ignore-tags")] # [serde (default)] pub ignore_tags : Option < HashSet < TagHash > > } impl Default for TagsSettingsOverride { fn default () -> Self { TagsSettingsOverride { colors : None , ignore_tags : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct TagsSettingsOverride { # [serde (deserialize_with = "tag_color_de")] # [serde (default)] pub colors : Option < HashMap < TagHash , Color > > , # [serde (deserialize_with = "tag_set_de" , alias = "ignore-tags")] # [serde (default)] pub ignore_tags : Option < HashSet < TagHash > > } impl Default for TagsSettingsOverride { fn default () -> Self { Self { colors : None , ignore_tags : None } } } -# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PGPSettingsOverride { # [doc = " auto verify signed e-mail according to RFC3156"] # [doc = " Default: true"] # [serde (alias = "auto-verify-signatures")] # [serde (default)] pub auto_verify_signatures : Option < bool > , # [doc = " auto decrypt encrypted e-mail"] # [doc = " Default: true"] # [serde (alias = "auto-decrypt")] # [serde (default)] pub auto_decrypt : Option < bool > , # [doc = " always sign sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-sign")] # [serde (default)] pub auto_sign : Option < bool > , # [doc = " Auto encrypt sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-encrypt")] # [serde (default)] pub auto_encrypt : Option < bool > , # [doc = " Default: None"] # [serde (alias = "sign-key")] # [serde (default)] pub sign_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "decrypt-key")] # [serde (default)] pub decrypt_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "encrypt-key")] # [serde (default)] pub encrypt_key : Option < Option < String > > , # [doc = " Allow remote lookups"] # [doc = " Default: None"] # [serde (alias = "allow-remote-lookups")] # [serde (default)] pub allow_remote_lookup : Option < ToggleFlag > , # [doc = " Remote lookup mechanisms."] # [doc = " Default: \"local,wkd\""] # [cfg_attr (feature = "gpgme" , serde (alias = "remote-lookup-mechanisms"))] # [cfg (feature = "gpgme")] # [serde (default)] pub remote_lookup_mechanisms : Option < melib :: gpgme :: LocateKey > , # [cfg (not (feature = "gpgme"))] # [cfg_attr (not (feature = "gpgme") , serde (alias = "remote-lookup-mechanisms"))] # [serde (default)] pub remote_lookup_mechanisms : Option < String > } impl Default for PGPSettingsOverride { fn default () -> Self { PGPSettingsOverride { auto_verify_signatures : None , auto_decrypt : None , auto_sign : None , auto_encrypt : None , sign_key : None , decrypt_key : None , encrypt_key : None , allow_remote_lookup : None , remote_lookup_mechanisms : None } } } +# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PGPSettingsOverride { # [doc = " auto verify signed e-mail according to RFC3156"] # [doc = " Default: true"] # [serde (alias = "auto-verify-signatures")] # [serde (default)] pub auto_verify_signatures : Option < bool > , # [doc = " auto decrypt encrypted e-mail"] # [doc = " Default: true"] # [serde (alias = "auto-decrypt")] # [serde (default)] pub auto_decrypt : Option < bool > , # [doc = " always sign sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-sign")] # [serde (default)] pub auto_sign : Option < bool > , # [doc = " Auto encrypt sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-encrypt")] # [serde (default)] pub auto_encrypt : Option < bool > , # [doc = " Default: None"] # [serde (alias = "sign-key")] # [serde (default)] pub sign_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "decrypt-key")] # [serde (default)] pub decrypt_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "encrypt-key")] # [serde (default)] pub encrypt_key : Option < Option < String > > , # [doc = " Allow remote lookups"] # [doc = " Default: None"] # [serde (alias = "allow-remote-lookups")] # [serde (default)] pub allow_remote_lookup : Option < ToggleFlag > , # [doc = " Remote lookup mechanisms."] # [doc = " Default: \"local,wkd\""] # [cfg_attr (feature = "gpgme" , serde (alias = "remote-lookup-mechanisms"))] # [cfg (feature = "gpgme")] # [serde (default)] pub remote_lookup_mechanisms : Option < melib :: gpgme :: LocateKey > , # [cfg (not (feature = "gpgme"))] # [cfg_attr (not (feature = "gpgme") , serde (alias = "remote-lookup-mechanisms"))] # [serde (default)] pub remote_lookup_mechanisms : Option < String > } impl Default for PGPSettingsOverride { fn default () -> Self { Self { auto_verify_signatures : None , auto_decrypt : None , auto_sign : None , auto_encrypt : None , sign_key : None , decrypt_key : None , encrypt_key : None , allow_remote_lookup : None , remote_lookup_mechanisms : None } } } diff --git a/meli/src/conf/pgp.rs b/meli/src/conf/pgp.rs index 1954a59c..637d1e75 100644 --- a/meli/src/conf/pgp.rs +++ b/meli/src/conf/pgp.rs @@ -91,7 +91,7 @@ fn default_lookup_mechanism() -> melib::gpgme::LocateKey { impl Default for PGPSettings { fn default() -> Self { - PGPSettings { + Self { auto_verify_signatures: true, auto_decrypt: true, auto_sign: false, diff --git a/meli/src/conf/terminal.rs b/meli/src/conf/terminal.rs index 8604aa76..cc6ba130 100644 --- a/meli/src/conf/terminal.rs +++ b/meli/src/conf/terminal.rs @@ -55,7 +55,7 @@ pub struct TerminalSettings { impl Default for TerminalSettings { fn default() -> Self { - TerminalSettings { + Self { theme: "dark".to_string(), themes: Themes::default(), ascii_drawing: false, diff --git a/meli/src/conf/themes.rs b/meli/src/conf/themes.rs index be663813..5474a26e 100644 --- a/meli/src/conf/themes.rs +++ b/meli/src/conf/themes.rs @@ -387,37 +387,37 @@ enum ThemeValue { impl From<&'static str> for ThemeValue { fn from(from: &'static str) -> Self { - ThemeValue::Link(from.into(), ColorField::LikeSelf) + Self::Link(from.into(), ColorField::LikeSelf) } } impl From<&'static str> for ThemeValue { fn from(from: &'static str) -> Self { - ThemeValue::Link(from.into(), ()) + Self::Link(from.into(), ()) } } impl From for ThemeValue { fn from(from: Color) -> Self { - ThemeValue::Value(from) + Self::Value(from) } } impl From for ThemeValue { fn from(from: Attr) -> Self { - ThemeValue::Value(from) + Self::Value(from) } } impl Default for ThemeValue { fn default() -> Self { - ThemeValue::Value(Color::Default) + Self::Value(Color::Default) } } impl Default for ThemeValue { fn default() -> Self { - ThemeValue::Value(Attr::DEFAULT) + Self::Value(Attr::DEFAULT) } } @@ -428,11 +428,11 @@ impl<'de> Deserialize<'de> for ThemeValue { { if let Ok(s) = ::deserialize(deserializer) { if let Some(stripped) = s.strip_prefix('$') { - Ok(ThemeValue::Alias(stripped.to_string().into())) + Ok(Self::Alias(stripped.to_string().into())) } else if let Ok(c) = Attr::from_string_de::<'de, D, String>(s.clone()) { - Ok(ThemeValue::Value(c)) + Ok(Self::Value(c)) } else { - Ok(ThemeValue::Link(s.into(), ())) + Ok(Self::Link(s.into(), ())) } } else { Err(de::Error::custom("invalid theme attribute value")) @@ -446,9 +446,9 @@ impl Serialize for ThemeValue { S: Serializer, { match self { - ThemeValue::Value(s) => s.serialize(serializer), - ThemeValue::Alias(s) => format!("${}", s).serialize(serializer), - ThemeValue::Link(s, ()) => serializer.serialize_str(s.as_ref()), + Self::Value(s) => s.serialize(serializer), + Self::Alias(s) => format!("${}", s).serialize(serializer), + Self::Link(s, ()) => serializer.serialize_str(s.as_ref()), } } } @@ -459,15 +459,11 @@ impl Serialize for ThemeValue { S: Serializer, { match self { - ThemeValue::Value(s) => s.serialize(serializer), - ThemeValue::Alias(s) => format!("${}", s).serialize(serializer), - ThemeValue::Link(s, ColorField::LikeSelf) => serializer.serialize_str(s.as_ref()), - ThemeValue::Link(s, ColorField::Fg) => { - serializer.serialize_str(format!("{}.fg", s).as_ref()) - } - ThemeValue::Link(s, ColorField::Bg) => { - serializer.serialize_str(format!("{}.bg", s).as_ref()) - } + Self::Value(s) => s.serialize(serializer), + Self::Alias(s) => format!("${}", s).serialize(serializer), + Self::Link(s, ColorField::LikeSelf) => serializer.serialize_str(s.as_ref()), + Self::Link(s, ColorField::Fg) => serializer.serialize_str(format!("{}.fg", s).as_ref()), + Self::Link(s, ColorField::Bg) => serializer.serialize_str(format!("{}.bg", s).as_ref()), } } } @@ -479,21 +475,21 @@ impl<'de> Deserialize<'de> for ThemeValue { { if let Ok(s) = ::deserialize(deserializer) { if let Some(stripped) = s.strip_prefix('$') { - Ok(ThemeValue::Alias(stripped.to_string().into())) + Ok(Self::Alias(stripped.to_string().into())) } else if let Ok(c) = Color::from_string_de::<'de, D>(s.clone()) { - Ok(ThemeValue::Value(c)) + Ok(Self::Value(c)) } else if s.ends_with(".fg") { - Ok(ThemeValue::Link( + Ok(Self::Link( s[..s.len() - 3].to_string().into(), ColorField::Fg, )) } else if s.ends_with(".bg") { - Ok(ThemeValue::Link( + Ok(Self::Link( s[..s.len() - 3].to_string().into(), ColorField::Bg, )) } else { - Ok(ThemeValue::Link(s.into(), ColorField::LikeSelf)) + Ok(Self::Link(s.into(), ColorField::LikeSelf)) } } else { Err(de::Error::custom("invalid theme color value")) @@ -569,7 +565,7 @@ mod regexp { impl Eq for RegexpWrapper {} impl PartialEq for RegexpWrapper { - fn eq(&self, other: &RegexpWrapper) -> bool { + fn eq(&self, other: &Self) -> bool { self.0.as_str().eq(other.0.as_str()) } } @@ -827,7 +823,7 @@ impl<'de> Deserialize<'de> for Themes { attrs: Option>, } - let mut ret = Themes::default(); + let mut ret = Self::default(); let mut s = ::deserialize(deserializer)?; for tk in s.other_themes.keys() { ret.other_themes.insert(tk.clone(), ret.dark.clone()); @@ -1217,10 +1213,10 @@ impl Themes { } pub fn validate(&self) -> Result<()> { let hash_set: HashSet<&'static str> = DEFAULT_KEYS.iter().copied().collect(); - Themes::validate_keys("light", &self.light, &hash_set)?; - Themes::validate_keys("dark", &self.dark, &hash_set)?; + Self::validate_keys("light", &self.light, &hash_set)?; + Self::validate_keys("dark", &self.dark, &hash_set)?; for (name, t) in self.other_themes.iter() { - Themes::validate_keys(name, t, &hash_set)?; + Self::validate_keys(name, t, &hash_set)?; } if let Err(err) = is_cyclic(&self.light) { return Err(Error::new(format!("light theme contains a cycle: {}", err))); @@ -1288,7 +1284,7 @@ impl std::fmt::Display for Themes { impl Default for Themes { #[allow(clippy::needless_update)] - fn default() -> Themes { + fn default() -> Self { let mut light = IndexMap::default(); let mut dark = IndexMap::default(); let other_themes = IndexMap::default(); @@ -1734,7 +1730,7 @@ impl Default for Themes { add!("pager.highlight_search", light = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD }); add!("pager.highlight_search_current", light = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD }); - Themes { + Self { light: Theme { keys: light, attr_aliases: Default::default(), @@ -2085,7 +2081,7 @@ fn is_cyclic(theme: &Theme) -> std::result::Result<(), String> { fn test_theme_parsing() { /* MUST SUCCEED: default themes should be valid */ let def = Themes::default(); - assert!(def.validate().is_ok()); + def.validate().unwrap(); /* MUST SUCCEED: new user theme `hunter2`, theme `dark` has user * redefinitions */ const TEST_STR: &str = r#"[dark] @@ -2121,27 +2117,27 @@ fn test_theme_parsing() { ), Color::Byte(15), // White ); - assert!(parsed.validate().is_ok()); + parsed.validate().unwrap(); /* MUST FAIL: theme `dark` contains a cycle */ const HAS_CYCLE: &str = r#"[dark] "mail.listing.compact.even" = { fg = "mail.listing.compact.odd" } "mail.listing.compact.odd" = { fg = "mail.listing.compact.even" } "#; let parsed: Themes = toml::from_str(HAS_CYCLE).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); /* MUST FAIL: theme `dark` contains an invalid key */ const HAS_INVALID_KEYS: &str = r#"[dark] "asdfsafsa" = { fg = "Black" } "#; let parsed: std::result::Result = toml::from_str(HAS_INVALID_KEYS); - assert!(parsed.is_err()); + parsed.unwrap_err(); /* MUST SUCCEED: alias $Jebediah resolves to a valid color */ const TEST_ALIAS_STR: &str = r##"[dark] color_aliases= { "Jebediah" = "#b4da55" } "mail.listing.tag_default" = { fg = "$Jebediah" } "##; let parsed: Themes = toml::from_str(TEST_ALIAS_STR).unwrap(); - assert!(parsed.validate().is_ok()); + parsed.validate().unwrap(); assert_eq!( unlink_fg( &parsed.dark, @@ -2156,42 +2152,42 @@ color_aliases= { "Jebediah" = "#b4da55" } "mail.listing.tag_default" = { fg = "$Jebedia" } "##; let parsed: Themes = toml::from_str(TEST_INVALID_ALIAS_STR).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); /* MUST FAIL: Color alias $Jebediah is defined as itself */ const TEST_CYCLIC_ALIAS_STR: &str = r#"[dark] color_aliases= { "Jebediah" = "$Jebediah" } "mail.listing.tag_default" = { fg = "$Jebediah" } "#; let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); /* MUST FAIL: Attr alias $Jebediah is defined as itself */ const TEST_CYCLIC_ALIAS_ATTR_STR: &str = r#"[dark] attr_aliases= { "Jebediah" = "$Jebediah" } "mail.listing.tag_default" = { attrs = "$Jebediah" } "#; let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_ATTR_STR).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); /* MUST FAIL: alias $Jebediah resolves to a cycle */ const TEST_CYCLIC_ALIAS_STR_2: &str = r#"[dark] color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default" } "mail.listing.tag_default" = { fg = "$Jebediah" } "#; let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR_2).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); /* MUST SUCCEED: alias $Jebediah resolves to a key's field */ const TEST_CYCLIC_ALIAS_STR_3: &str = r#"[dark] color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default.bg" } "mail.listing.tag_default" = { fg = "$Jebediah", bg = "Black" } "#; let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR_3).unwrap(); - assert!(parsed.validate().is_ok()); + parsed.validate().unwrap(); /* MUST FAIL: alias $Jebediah resolves to an invalid key */ const TEST_INVALID_LINK_KEY_FIELD_STR: &str = r#"[dark] color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default.attrs" } "mail.listing.tag_default" = { fg = "$Jebediah", bg = "Black" } "#; let parsed: Themes = toml::from_str(TEST_INVALID_LINK_KEY_FIELD_STR).unwrap(); - assert!(parsed.validate().is_err()); + parsed.validate().unwrap_err(); } #[test] diff --git a/meli/src/contacts/editor.rs b/meli/src/contacts/editor.rs index 4503b55f..45329a6d 100644 --- a/meli/src/contacts/editor.rs +++ b/meli/src/contacts/editor.rs @@ -59,7 +59,7 @@ impl std::fmt::Display for ContactManager { impl ContactManager { pub fn new(context: &Context) -> Self { let theme_default: ThemeAttribute = crate::conf::value(context, "theme_default"); - ContactManager { + Self { id: ComponentId::default(), parent_id: None, card: Card::new(), @@ -227,14 +227,14 @@ impl Component for ContactManager { } } self.set_dirty(true); - if let UIEvent::InsertInput(_) = event { + if matches!(event, UIEvent::InsertInput(_)) { self.has_changes = true; } return true; } } ViewMode::ReadOnly => { - if let &mut UIEvent::Input(Key::Esc) = event { + if matches!(event, UIEvent::Input(Key::Esc)) { if self.can_quit_cleanly(context) { self.unrealize(context); } diff --git a/meli/src/contacts/list.rs b/meli/src/contacts/list.rs index 135f2b7e..bc4eed07 100644 --- a/meli/src/contacts/list.rs +++ b/meli/src/contacts/list.rs @@ -88,7 +88,7 @@ impl ContactList { index: i, }) .collect(); - ContactList { + Self { accounts, cursor_pos: 0, new_cursor_pos: 0, @@ -112,13 +112,13 @@ impl ContactList { } pub fn for_account(pos: usize, context: &Context) -> Self { - ContactList { + Self { account_pos: pos, ..Self::new(context) } } - fn initialize(&mut self, context: &mut Context) { + fn initialize(&mut self, context: &Context) { self.data_columns.clear(); let account = &context.accounts[self.account_pos]; let book = &account.address_book; @@ -274,7 +274,7 @@ impl ContactList { grid: &mut CellBuffer, area: Area, a: &AccountMenuEntry, - context: &mut Context, + context: &Context, ) { let width = area.width(); let must_highlight_account: bool = self.account_pos == a.index; diff --git a/meli/src/jobs.rs b/meli/src/jobs.rs index 233bae00..23240e18 100644 --- a/meli/src/jobs.rs +++ b/meli/src/jobs.rs @@ -176,7 +176,7 @@ impl JobExecutor { /// A queue that holds scheduled tasks. pub fn new(sender: Sender) -> Self { // Create a queue. - let mut ret = JobExecutor { + let mut ret = Self { global_queue: Arc::new(Injector::new()), workers: vec![], parkers: vec![], @@ -306,7 +306,7 @@ impl JobExecutor { ) } - pub fn create_timer(self: Arc, interval: Duration, value: Duration) -> Timer { + pub fn create_timer(self: Arc, interval: Duration, value: Duration) -> Timer { let timer = TimerPrivate { interval, cancel: Arc::new(Mutex::new(false)), diff --git a/meli/src/jobs_view.rs b/meli/src/jobs_view.rs index 8aa0394c..18c128cb 100644 --- a/meli/src/jobs_view.rs +++ b/meli/src/jobs_view.rs @@ -110,7 +110,7 @@ impl JobManager { } } - fn initialize(&mut self, context: &mut Context) { + fn initialize(&mut self, context: &Context) { self.set_dirty(true); let mut entries = (*context.main_loop_handler.job_executor.jobs.lock().unwrap()).clone(); diff --git a/meli/src/lib.rs b/meli/src/lib.rs index d421e850..aea71190 100644 --- a/meli/src/lib.rs +++ b/meli/src/lib.rs @@ -19,7 +19,47 @@ * along with meli. If not, see . */ -#![deny(rustdoc::redundant_explicit_links)] +#![deny( + rustdoc::redundant_explicit_links, + /* groups */ + clippy::correctness, + clippy::suspicious, + clippy::complexity, + clippy::perf, + clippy::cargo, + clippy::nursery, + clippy::style, + /* restriction */ + clippy::dbg_macro, + clippy::rc_buffer, + clippy::as_underscore, + clippy::assertions_on_result_states, + /* rustdoc */ + rustdoc::broken_intra_doc_links, + /* pedantic */ + //clippy::cast_lossless, + //clippy::cast_possible_wrap, + //clippy::ptr_as_ptr, + clippy::bool_to_int_with_if, + clippy::borrow_as_ptr, + clippy::cast_ptr_alignment, + clippy::large_futures, + clippy::waker_clone_wake, + clippy::unused_enumerate_index, + clippy::unnecessary_fallible_conversions, + clippy::struct_field_names, + clippy::manual_hash_one, + clippy::into_iter_without_iter, +)] +#![allow( + clippy::option_if_let_else, + clippy::missing_const_for_fn, + clippy::significant_drop_tightening, + clippy::multiple_crate_versions, + clippy::significant_drop_in_scrutinee, + clippy::cognitive_complexity, + clippy::manual_clamp +)] //! //! This crate contains the frontend stuff of the application. The application diff --git a/meli/src/mail/compose.rs b/meli/src/mail/compose.rs index 14aab2ee..261cf806 100644 --- a/meli/src/mail/compose.rs +++ b/meli/src/mail/compose.rs @@ -134,12 +134,12 @@ enum ViewMode { impl ViewMode { #[inline] fn is_edit(&self) -> bool { - matches!(self, ViewMode::Edit) + matches!(self, Self::Edit) } #[inline] fn is_edit_attachments(&self) -> bool { - matches!(self, ViewMode::EditAttachments { .. }) + matches!(self, Self::EditAttachments { .. }) } } @@ -169,7 +169,7 @@ impl Composer { pager.set_show_scrollbar(true); let mut form = FormWidget::default(); form.set_cursor(2); - Composer { + Self { reply_context: None, account_hash: AccountHash::default(), cursor: Cursor::Headers, @@ -195,9 +195,9 @@ impl Composer { } pub fn with_account(account_hash: AccountHash, context: &Context) -> Self { - let mut ret = Composer { + let mut ret = Self { account_hash, - ..Composer::new(context) + ..Self::new(context) }; // Add user's custom hooks. @@ -248,7 +248,7 @@ impl Composer { bytes: &[u8], context: &Context, ) -> Result { - let mut ret = Composer::with_account(account_hash, context); + let mut ret = Self::with_account(account_hash, context); // Add user's custom hooks. for hook in account_settings!(context[account_hash].composing.custom_compose_hooks) .iter() @@ -273,10 +273,10 @@ impl Composer { pub fn reply_to( coordinates @ (account_hash, _, _): (AccountHash, MailboxHash, EnvelopeHash), reply_body: String, - context: &mut Context, + context: &Context, reply_to_all: bool, ) -> Self { - let mut ret = Composer::with_account(account_hash, context); + let mut ret = Self::with_account(account_hash, context); // Add user's custom hooks. for hook in account_settings!(context[account_hash].composing.custom_compose_hooks) .iter() @@ -451,9 +451,9 @@ impl Composer { pub fn reply_to_select( coordinates @ (account_hash, _, _): (AccountHash, MailboxHash, EnvelopeHash), reply_body: String, - context: &mut Context, + context: &Context, ) -> Self { - let mut ret = Composer::reply_to(coordinates, reply_body, context, false); + let mut ret = Self::reply_to(coordinates, reply_body, context, false); let account = &context.accounts[&account_hash]; let parent_message = account.collection.get_env(coordinates.2); /* If message is from a mailing list and we detect a List-Post header, ask @@ -499,17 +499,17 @@ impl Composer { pub fn reply_to_author( coordinates: (AccountHash, MailboxHash, EnvelopeHash), reply_body: String, - context: &mut Context, + context: &Context, ) -> Self { - Composer::reply_to(coordinates, reply_body, context, false) + Self::reply_to(coordinates, reply_body, context, false) } pub fn reply_to_all( coordinates: (AccountHash, MailboxHash, EnvelopeHash), reply_body: String, - context: &mut Context, + context: &Context, ) -> Self { - Composer::reply_to(coordinates, reply_body, context, true) + Self::reply_to(coordinates, reply_body, context, true) } pub fn forward( @@ -517,9 +517,9 @@ impl Composer { bytes: &[u8], env: &Envelope, as_attachment: bool, - context: &mut Context, + context: &Context, ) -> Self { - let mut composer = Composer::with_account(coordinates.0, context); + let mut composer = Self::with_account(coordinates.0, context); let mut draft: Draft = Draft::default(); draft.set_header(HeaderName::SUBJECT, format!("Fwd: {}", env.subject())); let preamble = format!( @@ -1171,7 +1171,7 @@ impl Component for Composer { (ViewMode::Send(ref selector), UIEvent::FinishedUIDialog(id, result)) if selector.id() == *id => { - if let Some(true) = result.downcast_ref::() { + if matches!(result.downcast_ref::(), Some(true)) { self.update_draft(); match send_draft_async( #[cfg(feature = "gpgme")] @@ -1481,7 +1481,8 @@ impl Component for Composer { .. } = self; - for err in hooks + // Collect errors in a vector because filter_map borrows context + let errors = hooks .iter_mut() .filter_map(|h| { if let Err(err) = h(context, draft) { @@ -1490,8 +1491,8 @@ impl Component for Composer { None } }) - .collect::>() - { + .collect::>(); + for err in errors { context.replies.push_back(UIEvent::Notification { title: None, source: None, @@ -2479,7 +2480,7 @@ pub fn save_draft( pub fn send_draft_async( #[cfg(feature = "gpgme")] gpg_state: gpg::GpgComposeState, - context: &mut Context, + context: &Context, account_hash: AccountHash, mut draft: Draft, mailbox_type: SpecialUsageMailbox, @@ -2642,7 +2643,7 @@ hello world. let envelope = Envelope::from_bytes(raw_mail.as_bytes(), None).expect("Could not parse mail"); let tempdir = tempfile::tempdir().unwrap(); - let mut context = Context::new_mock(&tempdir); + let context = Context::new_mock(&tempdir); let account_hash = context.accounts[0].hash(); let mailbox_hash = MailboxHash::default(); let envelope_hash = envelope.hash(); @@ -2652,7 +2653,7 @@ hello world. let composer = Composer::reply_to( (account_hash, mailbox_hash, envelope_hash), String::new(), - &mut context, + &context, false, ); assert_eq!( @@ -2681,7 +2682,7 @@ hello world. let composer = Composer::reply_to( (account_hash, mailbox_hash, envelope_hash), String::new(), - &mut context, + &context, false, ); assert_eq!( diff --git a/meli/src/mail/compose/edit_attachments.rs b/meli/src/mail/compose/edit_attachments.rs index 92adb677..d2b9a70a 100644 --- a/meli/src/mail/compose/edit_attachments.rs +++ b/meli/src/mail/compose/edit_attachments.rs @@ -54,7 +54,7 @@ impl EditAttachments { let mut buttons = ButtonWidget::new(("Go Back".into(), FormButtonActions::Cancel)); buttons.set_focus(true); buttons.set_cursor(1); - EditAttachments { + Self { account_hash, mode: EditAttachmentMode::Overview, buttons, diff --git a/meli/src/mail/compose/gpg.rs b/meli/src/mail/compose/gpg.rs index 2407636c..6bcc2e85 100644 --- a/meli/src/mail/compose/gpg.rs +++ b/meli/src/mail/compose/gpg.rs @@ -53,7 +53,7 @@ impl KeySelection { local: bool, pattern: String, allow_remote_lookup: ToggleFlag, - context: &mut Context, + context: &Context, ) -> Result { use melib::gpgme::*; let mut ctx = Context::new()?; @@ -69,7 +69,7 @@ impl KeySelection { .spawn_specialized("gpg::keylist".into(), job); let mut progress_spinner = ProgressSpinner::new(8, context); progress_spinner.start(); - Ok(KeySelection::LoadingKeys { + Ok(Self::LoadingKeys { handle, secret, local, @@ -83,11 +83,11 @@ impl KeySelection { impl Component for KeySelection { fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { match self { - KeySelection::LoadingKeys { + Self::LoadingKeys { ref mut progress_spinner, .. } => progress_spinner.draw(grid, area.center_inside((2, 2)), context), - KeySelection::Error { ref err, .. } => { + Self::Error { ref err, .. } => { let theme_default = crate::conf::value(context, "theme_default"); grid.write_string( &err.to_string(), @@ -98,13 +98,13 @@ impl Component for KeySelection { Some(0), ); } - KeySelection::Loaded { ref mut widget, .. } => widget.draw(grid, area, context), + Self::Loaded { ref mut widget, .. } => widget.draw(grid, area, context), } } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { match self { - KeySelection::LoadingKeys { + Self::LoadingKeys { ref mut progress_spinner, ref mut handle, secret, @@ -131,10 +131,10 @@ impl Component for KeySelection { Ok(w) => { *self = w; } - Err(err) => *self = KeySelection::Error { err, id }, + Err(err) => *self = Self::Error { err, id }, } } else if !*local && allow_remote_lookup.is_ask() { - *self = KeySelection::Error { + *self = Self::Error { err: Error::new(format!( "No keys found for {}, perform remote lookup?", pattern @@ -142,12 +142,12 @@ impl Component for KeySelection { id, } } else { - *self = KeySelection::Error { + *self = Self::Error { err: Error::new(format!("No keys found for {}.", pattern)), id, } } - if let KeySelection::Error { ref err, .. } = self { + if let Self::Error { ref err, .. } = self { context.replies.push_back(UIEvent::StatusEvent( StatusEvent::DisplayMessage(err.to_string()), )); @@ -184,10 +184,10 @@ impl Component for KeySelection { context, )); widget.set_dirty(true); - *self = KeySelection::Loaded { widget, keys }; + *self = Self::Loaded { widget, keys }; } Ok(Some(Err(err))) => { - *self = KeySelection::Error { + *self = Self::Error { err, id: ComponentId::default(), }; @@ -197,30 +197,30 @@ impl Component for KeySelection { } _ => progress_spinner.process_event(event, context), }, - KeySelection::Error { .. } => false, - KeySelection::Loaded { ref mut widget, .. } => widget.process_event(event, context), + Self::Error { .. } => false, + Self::Loaded { ref mut widget, .. } => widget.process_event(event, context), } } fn is_dirty(&self) -> bool { match self { - KeySelection::LoadingKeys { + Self::LoadingKeys { ref progress_spinner, .. } => progress_spinner.is_dirty(), - KeySelection::Error { .. } => true, - KeySelection::Loaded { ref widget, .. } => widget.is_dirty(), + Self::Error { .. } => true, + Self::Loaded { ref widget, .. } => widget.is_dirty(), } } fn set_dirty(&mut self, value: bool) { match self { - KeySelection::LoadingKeys { + Self::LoadingKeys { ref mut progress_spinner, .. } => progress_spinner.set_dirty(value), - KeySelection::Error { .. } => {} - KeySelection::Loaded { ref mut widget, .. } => widget.set_dirty(value), + Self::Error { .. } => {} + Self::Loaded { ref mut widget, .. } => widget.set_dirty(value), } } @@ -228,21 +228,19 @@ impl Component for KeySelection { fn shortcuts(&self, context: &Context) -> ShortcutMaps { match self { - KeySelection::LoadingKeys { .. } | KeySelection::Error { .. } => { - ShortcutMaps::default() - } - KeySelection::Loaded { ref widget, .. } => widget.shortcuts(context), + Self::LoadingKeys { .. } | Self::Error { .. } => ShortcutMaps::default(), + Self::Loaded { ref widget, .. } => widget.shortcuts(context), } } fn id(&self) -> ComponentId { match self { - KeySelection::LoadingKeys { + Self::LoadingKeys { ref progress_spinner, .. } => progress_spinner.id(), - KeySelection::Error { ref id, .. } => *id, - KeySelection::Loaded { ref widget, .. } => widget.id(), + Self::Error { ref id, .. } => *id, + Self::Loaded { ref widget, .. } => widget.id(), } } } @@ -258,7 +256,7 @@ pub struct GpgComposeState { impl Default for GpgComposeState { fn default() -> Self { - GpgComposeState { + Self { sign_mail: ToggleFlag::Unset, encrypt_mail: ToggleFlag::Unset, encrypt_keys: vec![], diff --git a/meli/src/mail/listing.rs b/meli/src/mail/listing.rs index fa321793..cc1512cd 100644 --- a/meli/src/mail/listing.rs +++ b/meli/src/mail/listing.rs @@ -526,7 +526,7 @@ pub trait MailListingTrait: ListingTrait { match a { ListingAction::SetSeen => { if let Err(err) = account.set_flags( - env_hashes.clone(), + env_hashes, mailbox_hash, smallvec::smallvec![FlagOp::Set(Flag::SEEN)], ) { @@ -537,7 +537,7 @@ pub trait MailListingTrait: ListingTrait { } ListingAction::SetUnseen => { if let Err(err) = account.set_flags( - env_hashes.clone(), + env_hashes, mailbox_hash, smallvec::smallvec![FlagOp::UnSet(Flag::SEEN)], ) { @@ -548,7 +548,7 @@ pub trait MailListingTrait: ListingTrait { } ListingAction::Tag(TagAction::Add(ref tag_str)) => { if let Err(err) = account.set_flags( - env_hashes.clone(), + env_hashes, mailbox_hash, smallvec::smallvec![FlagOp::SetTag(tag_str.into())], ) { @@ -559,7 +559,7 @@ pub trait MailListingTrait: ListingTrait { } ListingAction::Tag(TagAction::Remove(ref tag_str)) => { if let Err(err) = account.set_flags( - env_hashes.clone(), + env_hashes, mailbox_hash, smallvec::smallvec![FlagOp::UnSetTag(tag_str.into())], ) { @@ -972,11 +972,11 @@ enum MenuEntryCursor { } impl std::ops::Sub for isize { - type Output = isize; + type Output = Self; - fn sub(self, other: MenuEntryCursor) -> isize { + fn sub(self, other: MenuEntryCursor) -> Self { if let MenuEntryCursor::Mailbox(v) = other { - v as isize - self + v as Self - self } else { self - 1 } @@ -2497,7 +2497,7 @@ impl Listing { }) .collect(); let first_account_hash = account_entries[0].hash; - let mut ret = Listing { + let mut ret = Self { component: Offline(OfflineListing::new(( first_account_hash, MailboxHash::default(), @@ -2635,7 +2635,7 @@ impl Listing { } /// Print a single account in the menu area. - fn print_account(&mut self, mut area: Area, aidx: usize, context: &mut Context) -> usize { + fn print_account(&mut self, mut area: Area, aidx: usize, context: &Context) -> usize { let account_y = self.menu.area().height() - area.height(); #[derive(Clone, Copy, Debug)] struct Line { diff --git a/meli/src/mail/listing/compact.rs b/meli/src/mail/listing/compact.rs index fa0ca835..308b9f63 100644 --- a/meli/src/mail/listing/compact.rs +++ b/meli/src/mail/listing/compact.rs @@ -899,7 +899,7 @@ impl std::fmt::Display for CompactListing { impl CompactListing { pub fn new(parent: ComponentId, coordinates: (AccountHash, MailboxHash)) -> Box { - Box::new(CompactListing { + Box::new(Self { cursor_pos: (AccountHash::default(), MailboxHash::default(), 0), new_cursor_pos: (coordinates.0, coordinates.1, 0), length: 0, diff --git a/meli/src/mail/listing/conversations.rs b/meli/src/mail/listing/conversations.rs index abb752f6..1da2ffba 100644 --- a/meli/src/mail/listing/conversations.rs +++ b/meli/src/mail/listing/conversations.rs @@ -793,7 +793,7 @@ impl ConversationsListing { if thread.has_attachments() { "📎" } else { "" }, if thread.snoozed() { "💤" } else { "" } )), - from: FromString(Address::display_name_slice(from).to_string()), + from: FromString(Address::display_name_slice(from)), tags: TagString(tags_string, colors), } } diff --git a/meli/src/mail/listing/offline.rs b/meli/src/mail/listing/offline.rs index d8c1b06c..99e3a3df 100644 --- a/meli/src/mail/listing/offline.rs +++ b/meli/src/mail/listing/offline.rs @@ -119,7 +119,7 @@ impl std::fmt::Display for OfflineListing { impl OfflineListing { pub fn new(cursor_pos: (AccountHash, MailboxHash)) -> Box { - Box::new(OfflineListing { + Box::new(Self { cursor_pos, _row_updates: SmallVec::new(), _selection: HashMap::default(), diff --git a/meli/src/mail/listing/plain.rs b/meli/src/mail/listing/plain.rs index 4dad7178..642d6985 100644 --- a/meli/src/mail/listing/plain.rs +++ b/meli/src/mail/listing/plain.rs @@ -667,7 +667,7 @@ impl std::fmt::Display for PlainListing { impl PlainListing { pub fn new(parent: ComponentId, coordinates: (AccountHash, MailboxHash)) -> Box { - Box::new(PlainListing { + Box::new(Self { cursor_pos: (AccountHash::default(), MailboxHash::default(), 0), new_cursor_pos: (coordinates.0, coordinates.1, 0), length: 0, diff --git a/meli/src/mail/listing/thread.rs b/meli/src/mail/listing/thread.rs index f3b6911c..a0b026f4 100644 --- a/meli/src/mail/listing/thread.rs +++ b/meli/src/mail/listing/thread.rs @@ -321,7 +321,7 @@ impl MailListingTrait for ThreadListing { prev_group = threads.find_group(thread_node.group); let mut entry_strings = self.make_entry_string(&envelope, context); - entry_strings.subject = SubjectString(ThreadListing::make_thread_entry( + entry_strings.subject = SubjectString(Self::make_thread_entry( &envelope, indentation, thread_node_hash, @@ -775,9 +775,9 @@ impl ThreadListing { pub fn new( parent: ComponentId, coordinates: (AccountHash, MailboxHash), - context: &mut Context, + context: &Context, ) -> Box { - Box::new(ThreadListing { + Box::new(Self { cursor_pos: (coordinates.0, MailboxHash::default(), 0), new_cursor_pos: (coordinates.0, coordinates.1, 0), length: 0, diff --git a/meli/src/mail/pgp.rs b/meli/src/mail/pgp.rs index d86db515..eadac5c7 100644 --- a/meli/src/mail/pgp.rs +++ b/meli/src/mail/pgp.rs @@ -141,13 +141,13 @@ pub fn encrypt_filter( Default::default(), ctx.encrypt(sign_keys, encrypt_keys, data)?.await?, ); - a.content_disposition = ContentDisposition::from(r#"attachment; filename="msg.asc""#.as_bytes()); + a.content_disposition = ContentDisposition::from(br#"attachment; filename="msg.asc""#); a }; - let mut a: AttachmentBuilder = AttachmentBuilder::new("Version: 1\n".as_bytes()); + let mut a: AttachmentBuilder = AttachmentBuilder::new(b"Version: 1\n"); - a.set_content_type_from_bytes("application/pgp-encrypted".as_bytes()); - a.set_content_disposition(ContentDisposition::from("attachment".as_bytes())); + a.set_content_type_from_bytes(b"application/pgp-encrypted"); + a.set_content_disposition(ContentDisposition::from(b"attachment")); let parts = vec![a, sig_attachment.into()]; let boundary = ContentType::make_boundary(&parts); Ok(Attachment::new( diff --git a/meli/src/mail/status.rs b/meli/src/mail/status.rs index 754eb8d5..c59f48fd 100644 --- a/meli/src/mail/status.rs +++ b/meli/src/mail/status.rs @@ -41,7 +41,7 @@ impl std::fmt::Display for AccountStatus { } impl AccountStatus { - pub fn new(account_pos: usize, theme_default: ThemeAttribute) -> AccountStatus { + pub fn new(account_pos: usize, theme_default: ThemeAttribute) -> Self { let default_cell = { let mut ret = Cell::with_char(' '); ret.set_fg(theme_default.fg) @@ -54,7 +54,7 @@ impl AccountStatus { content.grid_mut().set_growable(true); _ = content.resize(80, 20); - AccountStatus { + Self { cursor: (0, 0), account_pos, content, diff --git a/meli/src/mail/view.rs b/meli/src/mail/view.rs index 7bac9154..1b9d89b8 100644 --- a/meli/src/mail/view.rs +++ b/meli/src/mail/view.rs @@ -94,7 +94,7 @@ impl MailView { initialize_now: bool, context: &mut Context, ) -> Self { - let mut ret = MailView { + let mut ret = Self { coordinates, dirty: true, contact_selector: None, diff --git a/meli/src/mail/view/envelope.rs b/meli/src/mail/view/envelope.rs index ad87fd9a..78ea1220 100644 --- a/meli/src/mail/view/envelope.rs +++ b/meli/src/mail/view/envelope.rs @@ -87,7 +87,7 @@ impl EnvelopeView { ) -> Self { let view_settings = view_settings.unwrap_or_default(); let body = Box::new(AttachmentBuilder::new(&mail.bytes).build()); - let mut ret = EnvelopeView { + let mut ret = Self { pager: pager.unwrap_or_default(), subview, dirty: true, @@ -221,7 +221,7 @@ impl EnvelopeView { } } for a in parts { - EnvelopeView::attachment_to_display_helper( + Self::attachment_to_display_helper( a, main_loop_handler, active_jobs, @@ -271,7 +271,7 @@ impl EnvelopeView { job_id: handle.job_id, display: { let mut v = vec![]; - EnvelopeView::attachment_to_display_helper( + Self::attachment_to_display_helper( &parts[0], main_loop_handler, active_jobs, @@ -288,7 +288,7 @@ impl EnvelopeView { inner: Box::new(a.clone()), display: { let mut v = vec![]; - EnvelopeView::attachment_to_display_helper( + Self::attachment_to_display_helper( &parts[0], main_loop_handler, active_jobs, @@ -342,7 +342,7 @@ impl EnvelopeView { } _ => { for a in parts { - EnvelopeView::attachment_to_display_helper( + Self::attachment_to_display_helper( a, main_loop_handler, active_jobs, @@ -1269,7 +1269,7 @@ impl Component for EnvelopeView { .replies .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); if let Some(attachment) = self.open_attachment(lidx, context) { - if let Ok(()) = crate::mailcap::MailcapEntry::execute(attachment, context) { + if crate::mailcap::MailcapEntry::execute(attachment, context).is_ok() { self.set_dirty(true); } else { context.replies.push_back(UIEvent::StatusEvent( @@ -1411,7 +1411,7 @@ impl Component for EnvelopeView { ContentType::MessageRfc822 => { match Mail::new(attachment.body().to_vec(), Some(Flag::SEEN)) { Ok(wrapper) => { - self.subview = Some(Box::new(EnvelopeView::new( + self.subview = Some(Box::new(Self::new( wrapper, None, None, diff --git a/meli/src/mail/view/filters.rs b/meli/src/mail/view/filters.rs index d49059b1..91de8970 100644 --- a/meli/src/mail/view/filters.rs +++ b/meli/src/mail/view/filters.rs @@ -76,7 +76,7 @@ impl std::fmt::Display for ViewFilter { } impl ViewFilter { - pub fn new_html(body: &Attachment, context: &mut Context) -> Result { + pub fn new_html(body: &Attachment, context: &Context) -> Result { fn run(cmd: &str, args: &[&str], bytes: &[u8]) -> Result { let mut html_filter = Command::new(cmd) .args(args) @@ -306,11 +306,7 @@ impl ViewFilter { }) } - fn html_process_event( - _self: &mut ViewFilter, - event: &mut UIEvent, - context: &mut Context, - ) -> bool { + fn html_process_event(_self: &mut Self, event: &mut UIEvent, context: &mut Context) -> bool { if matches!(event, UIEvent::Input(key) if *key == context.settings.shortcuts.envelope_view.open_html) { let command = context @@ -346,9 +342,9 @@ impl ViewFilter { )) }) { Ok((p, child)) => { - context.replies.push_back(UIEvent::StatusEvent( - StatusEvent::UpdateSubStatus(command.to_string()), - )); + context + .replies + .push_back(UIEvent::StatusEvent(StatusEvent::UpdateSubStatus(command))); context.temp_files.push(p); context.children.push(child); } diff --git a/meli/src/mail/view/state.rs b/meli/src/mail/view/state.rs index 0cda494a..91f6f5ae 100644 --- a/meli/src/mail/view/state.rs +++ b/meli/src/mail/view/state.rs @@ -24,7 +24,7 @@ use melib::{text::Truncate, Envelope, Error, Mail, Result}; use super::{EnvelopeView, MailView, ViewSettings}; use crate::{jobs::JoinHandle, mailbox_settings, Component, Context, ShortcutMaps, UIEvent}; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum PendingReplyAction { Reply, ReplyToAuthor, @@ -149,7 +149,7 @@ impl MailViewState { }), context.main_loop_handler.clone(), )); - self_.state = MailViewState::Loaded { + self_.state = Self::Loaded { env, bytes, env_view, @@ -192,7 +192,7 @@ impl MailViewState { impl Default for MailViewState { fn default() -> Self { - MailViewState::Init { + Self::Init { pending_action: None, } } diff --git a/meli/src/mail/view/thread.rs b/meli/src/mail/view/thread.rs index 57b2951f..11c12ddb 100644 --- a/meli/src/mail/view/thread.rs +++ b/meli/src/mail/view/thread.rs @@ -86,7 +86,7 @@ impl ThreadView { focus: Option, context: &mut Context, ) -> Self { - let mut view = ThreadView { + let mut view = Self { reversed: false, coordinates, thread_group, @@ -147,10 +147,8 @@ impl ThreadView { { self.entries[new_cursor].hidden = old_entries[old_cursor].hidden; old_cursor += 1; - new_cursor += 1; - } else { - new_cursor += 1; } + new_cursor += 1; self.recalc_visible_entries(); } @@ -898,7 +896,10 @@ impl Component for ThreadView { } fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool { - if let (UIEvent::Action(Listing(OpenInNewTab)), false) = (&event, self.entries.is_empty()) { + if matches!( + (&event, self.entries.is_empty()), + (UIEvent::Action(Listing(OpenInNewTab)), false) + ) { // Handle this before self.mailview does let mut new_tab = Self::new( self.coordinates, diff --git a/meli/src/mailbox_management.rs b/meli/src/mailbox_management.rs index 5aa1d5d4..595fc322 100644 --- a/meli/src/mailbox_management.rs +++ b/meli/src/mailbox_management.rs @@ -96,7 +96,7 @@ impl MailboxManager { let theme_default = crate::conf::value(context, "theme_default"); let mut data_columns = DataColumns::default(); data_columns.theme_config.set_single_theme(theme_default); - MailboxManager { + Self { cursor_pos: 0, new_cursor_pos: 0, account_hash, @@ -117,7 +117,7 @@ impl MailboxManager { } } - fn initialize(&mut self, context: &mut Context) { + fn initialize(&mut self, context: &Context) { let account = &context.accounts[self.account_pos]; self.length = account.mailbox_entries.len(); let mut entries = account.mailbox_entries.clone(); diff --git a/meli/src/mailcap.rs b/meli/src/mailcap.rs index fc47ea2b..cf68e600 100644 --- a/meli/src/mailcap.rs +++ b/meli/src/mailcap.rs @@ -24,7 +24,6 @@ //! Implements [RFC 1524 A User Agent Configuration Mechanism For Multimedia //! Mail Format Information](https://www.rfc-editor.org/rfc/inline-errata/rfc1524.html) use std::{ - collections::HashMap, io::{Read, Write}, path::PathBuf, process::{Command, Stdio}, @@ -77,7 +76,6 @@ impl MailcapEntry { } } - let mut hash_map = HashMap::new(); let mut content = String::new(); std::fs::File::open(mailcap_path.as_path())?.read_to_string(&mut content)?; @@ -111,13 +109,12 @@ impl MailcapEntry { } } - result = Some(MailcapEntry { + result = Some(Self { command: cmd.to_string(), copiousoutput, }); break; } - hash_map.insert(key.to_string(), cmd.to_string()); } else { let mut parts_iter = l.split(';'); let key = parts_iter.next().unwrap(); @@ -134,25 +131,23 @@ impl MailcapEntry { } } - result = Some(MailcapEntry { + result = Some(Self { command: cmd.to_string(), copiousoutput, }); break; } - hash_map.insert(key.to_string(), cmd.to_string()); } } match result { None => Err(Error::new("Not found")), - Some(MailcapEntry { + Some(Self { command, copiousoutput, }) => { let parts = split_command!(command); let (cmd, args) = (parts[0], &parts[1..]); - let mut f = None; let mut needs_stdin = true; let params = a.parameters(); /* [ref:TODO]: See mailcap(5) @@ -173,7 +168,6 @@ impl MailcapEntry { true, )?; let p = _f.path().display().to_string(); - f = Some(_f); Ok(p) } "%t" => Ok(a.content_type().to_string()), diff --git a/meli/src/notifications.rs b/meli/src/notifications.rs index 40dc3e0c..4d625b64 100644 --- a/meli/src/notifications.rs +++ b/meli/src/notifications.rs @@ -49,7 +49,7 @@ mod dbus { impl DbusNotifications { pub fn new(context: &Context) -> Self { - DbusNotifications { + Self { rate_limit: RateLimit::new( 1000, 1000, @@ -183,7 +183,7 @@ pub struct NotificationCommand { impl NotificationCommand { pub fn new() -> Self { - NotificationCommand::default() + Self::default() } } @@ -213,12 +213,13 @@ impl Component for NotificationCommand { } } - let mut script = context.settings.notifications.script.as_ref(); - if *kind == Some(NotificationType::NewMail) + let script = if *kind == Some(NotificationType::NewMail) && context.settings.notifications.new_mail_script.is_some() { - script = context.settings.notifications.new_mail_script.as_ref(); - } + context.settings.notifications.new_mail_script.as_ref() + } else { + context.settings.notifications.script.as_ref() + }; if let Some(ref bin) = script { match Command::new(bin) diff --git a/meli/src/sqlite3.rs b/meli/src/sqlite3.rs index 29bc7170..de238bb9 100644 --- a/meli/src/sqlite3.rs +++ b/meli/src/sqlite3.rs @@ -216,7 +216,7 @@ pub async fn insert( .unwrap_or_default(), envelope.field_references_to_string(), i64::from(envelope.flags().bits()), - if envelope.has_attachments() { 1 } else { 0 }, + i32::from(envelope.has_attachments()), body, envelope.date().to_be_bytes().to_vec() ], @@ -253,7 +253,7 @@ pub fn remove(env_hash: EnvelopeHash) -> Result<()> { Ok(()) } -pub fn index(context: &mut crate::state::Context, account_index: usize) -> ResultFuture<()> { +pub fn index(context: &crate::state::Context, account_index: usize) -> ResultFuture<()> { let account = &context.accounts[account_index]; let (acc_name, acc_mutex, backend_mutex): (String, Arc>, Arc<_>) = ( account.name().to_string(), @@ -325,7 +325,7 @@ pub fn index(context: &mut crate::state::Context, account_index: usize) -> Resul .unwrap_or_default(), e.field_references_to_string(), i64::from(e.flags().bits()), - if e.has_attachments() { 1 } else { 0 }, + i32::from(e.has_attachments()), body, e.date().to_be_bytes().to_vec() ], diff --git a/meli/src/state.rs b/meli/src/state.rs index 8bf3e70e..2f183469 100644 --- a/meli/src/state.rs +++ b/meli/src/state.rs @@ -160,7 +160,7 @@ impl Context { } pub fn is_online_idx(&mut self, account_pos: usize) -> Result<()> { - let Context { + let Self { ref mut accounts, ref mut replies, .. @@ -241,7 +241,7 @@ impl Context { let accounts = accounts.into_iter().map(|acc| (acc.hash(), acc)).collect(); let working = Arc::new(()); let control = Arc::downgrade(&working); - Context { + Self { accounts, settings, dirty_areas: VecDeque::with_capacity(0), @@ -410,7 +410,7 @@ impl State { Screen::draw_horizontal_segment_no_color }); let message_box = DisplayMessageBox::new(&screen); - let mut s = State { + let mut s = Self { screen, child: None, mode: UIMode::Normal, @@ -703,7 +703,7 @@ impl State { } pub fn can_quit_cleanly(&mut self) -> bool { - let State { + let Self { ref mut components, ref context, .. @@ -800,7 +800,7 @@ impl State { }); return; } - match crate::sqlite3::index(&mut self.context, account_index) { + match crate::sqlite3::index(&self.context, account_index) { Ok(job) => { let handle = self .context @@ -928,7 +928,7 @@ impl State { )); self.overlay.insert(new.id(), new); - } else if let Action::ReloadConfiguration = action { + } else if matches!(action, Action::ReloadConfiguration) { match Settings::new().and_then(|new_settings| { let old_accounts = self .context diff --git a/meli/src/svg.rs b/meli/src/svg.rs index a85c565d..891146a8 100644 --- a/meli/src/svg.rs +++ b/meli/src/svg.rs @@ -37,7 +37,7 @@ impl std::fmt::Display for SVGScreenshotFilter { impl SVGScreenshotFilter { pub fn new() -> Self { - SVGScreenshotFilter { + Self { save_screenshot: false, id: ComponentId::default(), } @@ -431,20 +431,22 @@ impl Component for SVGScreenshotFilter { kind: None, }); } + fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { - if let UIEvent::Input(Key::F(6)) = event { + if matches!( + event, + UIEvent::Input(Key::F(6)) | UIEvent::CmdInput(Key::F(6)) + ) { self.save_screenshot = true; true - } else if let UIEvent::CmdInput(Key::F(6)) = event { - self.save_screenshot = true; - true - } else if let UIEvent::EmbeddedInput((Key::F(6), _)) = event { + } else if matches!(event, UIEvent::EmbeddedInput((Key::F(6), _))) { self.save_screenshot = true; false } else { false } } + fn set_dirty(&mut self, _value: bool) {} fn is_dirty(&self) -> bool { diff --git a/meli/src/terminal/braille.rs b/meli/src/terminal/braille.rs index 11f699a9..9d3e3b9a 100644 --- a/meli/src/terminal/braille.rs +++ b/meli/src/terminal/braille.rs @@ -145,7 +145,7 @@ pub struct BraillePixelIter { impl From<&[u16]> for BraillePixelIter { fn from(from: &[u16]) -> Self { - BraillePixelIter { + Self { columns: [ Braille16bitColumn { bitmaps: ( diff --git a/meli/src/terminal/color.rs b/meli/src/terminal/color.rs index 400c5b9b..3f2acb7d 100644 --- a/meli/src/terminal/color.rs +++ b/meli/src/terminal/color.rs @@ -70,39 +70,39 @@ impl Color { /// Returns the `u8` representation of the `Color`. pub fn as_byte(self) -> u8 { match self { - Color::Black => 0x00, - Color::Red => 0x01, - Color::Green => 0x02, - Color::Yellow => 0x03, - Color::Blue => 0x04, - Color::Magenta => 0x05, - Color::Cyan => 0x06, - Color::White => 0x07, - Color::Byte(b) => b, - Color::Rgb(_, _, _) => unreachable!(), - Color::Default => 0x00, + Self::Black => 0x00, + Self::Red => 0x01, + Self::Green => 0x02, + Self::Yellow => 0x03, + Self::Blue => 0x04, + Self::Magenta => 0x05, + Self::Cyan => 0x06, + Self::White => 0x07, + Self::Byte(b) => b, + Self::Rgb(_, _, _) => unreachable!(), + Self::Default => 0x00, } } pub fn from_byte(val: u8) -> Self { match val { - 0x00 => Color::Black, - 0x01 => Color::Red, - 0x02 => Color::Green, - 0x03 => Color::Yellow, - 0x04 => Color::Blue, - 0x05 => Color::Magenta, - 0x06 => Color::Cyan, - 0x07 => Color::White, - _ => Color::Default, + 0x00 => Self::Black, + 0x01 => Self::Red, + 0x02 => Self::Green, + 0x03 => Self::Yellow, + 0x04 => Self::Blue, + 0x05 => Self::Magenta, + 0x06 => Self::Cyan, + 0x07 => Self::White, + _ => Self::Default, } } pub fn write_fg(self, stdout: &mut crate::StateStdout) -> std::io::Result<()> { use std::io::Write; match self { - Color::Default => write!(stdout, "{}", termion::color::Fg(termion::color::Reset)), - Color::Rgb(r, g, b) => write!(stdout, "{}", termion::color::Fg(TermionRgb(r, g, b))), + Self::Default => write!(stdout, "{}", termion::color::Fg(termion::color::Reset)), + Self::Rgb(r, g, b) => write!(stdout, "{}", termion::color::Fg(TermionRgb(r, g, b))), _ => write!(stdout, "{}", termion::color::Fg(self.as_termion())), } } @@ -110,25 +110,25 @@ impl Color { pub fn write_bg(self, stdout: &mut crate::StateStdout) -> std::io::Result<()> { use std::io::Write; match self { - Color::Default => write!(stdout, "{}", termion::color::Bg(termion::color::Reset)), - Color::Rgb(r, g, b) => write!(stdout, "{}", termion::color::Bg(TermionRgb(r, g, b))), + Self::Default => write!(stdout, "{}", termion::color::Bg(termion::color::Reset)), + Self::Rgb(r, g, b) => write!(stdout, "{}", termion::color::Bg(TermionRgb(r, g, b))), _ => write!(stdout, "{}", termion::color::Bg(self.as_termion())), } } pub fn as_termion(self) -> AnsiValue { match self { - b @ Color::Black - | b @ Color::Red - | b @ Color::Green - | b @ Color::Yellow - | b @ Color::Blue - | b @ Color::Magenta - | b @ Color::Cyan - | b @ Color::White - | b @ Color::Default => AnsiValue(b.as_byte()), - Color::Byte(b) => AnsiValue(b), - Color::Rgb(_, _, _) => AnsiValue(0), + b @ Self::Black + | b @ Self::Red + | b @ Self::Green + | b @ Self::Yellow + | b @ Self::Blue + | b @ Self::Magenta + | b @ Self::Cyan + | b @ Self::White + | b @ Self::Default => AnsiValue(b.as_byte()), + Self::Byte(b) => AnsiValue(b), + Self::Rgb(_, _, _) => AnsiValue(0), } } @@ -393,14 +393,14 @@ impl Color { "Yellow4" => 100, "Yellow5" => 106, "Yellow6" => 148, - "Default" => return Ok(Color::Default), + "Default" => return Ok(Self::Default), s if s.starts_with('#') && s.len() == 7 && s[1..].as_bytes().iter().all(|&b| { b.is_ascii_digit() || (b'a'..=b'f').contains(&b) || (b'A'..=b'F').contains(&b) }) => { - return Ok(Color::Rgb( + return Ok(Self::Rgb( u8::from_str_radix(&s[1..3], 16) .map_err(|_| de::Error::custom("invalid `color` value"))?, u8::from_str_radix(&s[3..5], 16) @@ -415,7 +415,7 @@ impl Color { b.is_ascii_digit() || (b'a'..=b'f').contains(&b) || (b'A'..=b'F').contains(&b) }) => { - return Ok(Color::Rgb( + return Ok(Self::Rgb( 17 * u8::from_str_radix(&s[1..2], 16) .map_err(|_| de::Error::custom("invalid `color` value"))?, 17 * u8::from_str_radix(&s[2..3], 16) @@ -428,7 +428,7 @@ impl Color { .parse::() .map_err(|_| de::Error::custom("invalid `color` value"))?, }; - Ok(Color::Byte(byte)) + Ok(Self::Byte(byte)) } } @@ -438,7 +438,7 @@ impl<'de> Deserialize<'de> for Color { D: Deserializer<'de>, { if let Ok(s) = ::deserialize(deserializer) { - Color::from_string_de::<'de, D>(s) + Self::from_string_de::<'de, D>(s) } else { Err(de::Error::custom("invalid `color` value")) } @@ -494,266 +494,266 @@ impl Serialize for Color { S: Serializer, { match self { - Color::Black | Color::Byte(0) => serializer.serialize_str("Black"), - Color::Byte(1) => serializer.serialize_str("Maroon"), - Color::Green | Color::Byte(2) => serializer.serialize_str("Green"), - Color::Byte(3) => serializer.serialize_str("Olive"), - Color::Byte(4) => serializer.serialize_str("Navy"), - Color::Byte(5) | Color::Magenta => serializer.serialize_str("Purple"), - Color::Byte(6) | Color::Cyan => serializer.serialize_str("Teal"), - Color::Byte(7) => serializer.serialize_str("Silver"), - Color::Byte(8) => serializer.serialize_str("Grey"), - Color::Red | Color::Byte(9) => serializer.serialize_str("Red"), - Color::Byte(10) => serializer.serialize_str("Lime"), - Color::Yellow | Color::Byte(11) => serializer.serialize_str("Yellow"), - Color::Blue | Color::Byte(12) => serializer.serialize_str("Blue"), - Color::Byte(13) => serializer.serialize_str("Fuchsia"), - Color::Byte(14) => serializer.serialize_str("Aqua"), - Color::White | Color::Byte(15) => serializer.serialize_str("White"), - Color::Byte(16) => serializer.serialize_str("Grey0"), - Color::Byte(17) => serializer.serialize_str("NavyBlue"), - Color::Byte(18) => serializer.serialize_str("DarkBlue"), - Color::Byte(19) => serializer.serialize_str("Blue3"), - Color::Byte(20) => serializer.serialize_str("Blue3"), - Color::Byte(21) => serializer.serialize_str("Blue1"), - Color::Byte(22) => serializer.serialize_str("DarkGreen"), - Color::Byte(23) => serializer.serialize_str("DeepSkyBlue4"), - Color::Byte(24) => serializer.serialize_str("DeepSkyBlue4"), - Color::Byte(25) => serializer.serialize_str("DeepSkyBlue4"), - Color::Byte(26) => serializer.serialize_str("DodgerBlue3"), - Color::Byte(27) => serializer.serialize_str("DodgerBlue2"), - Color::Byte(28) => serializer.serialize_str("Green4"), - Color::Byte(29) => serializer.serialize_str("SpringGreen4"), - Color::Byte(30) => serializer.serialize_str("Turquoise4"), - Color::Byte(31) => serializer.serialize_str("DeepSkyBlue3"), - Color::Byte(32) => serializer.serialize_str("DeepSkyBlue3"), - Color::Byte(33) => serializer.serialize_str("DodgerBlue1"), - Color::Byte(34) => serializer.serialize_str("Green3"), - Color::Byte(35) => serializer.serialize_str("SpringGreen3"), - Color::Byte(36) => serializer.serialize_str("DarkCyan"), - Color::Byte(37) => serializer.serialize_str("LightSeaGreen"), - Color::Byte(38) => serializer.serialize_str("DeepSkyBlue2"), - Color::Byte(39) => serializer.serialize_str("DeepSkyBlue1"), - Color::Byte(40) => serializer.serialize_str("Green3"), - Color::Byte(41) => serializer.serialize_str("SpringGreen3"), - Color::Byte(42) => serializer.serialize_str("SpringGreen2"), - Color::Byte(43) => serializer.serialize_str("Cyan3"), - Color::Byte(44) => serializer.serialize_str("DarkTurquoise"), - Color::Byte(45) => serializer.serialize_str("Turquoise2"), - Color::Byte(46) => serializer.serialize_str("Green1"), - Color::Byte(47) => serializer.serialize_str("SpringGreen2"), - Color::Byte(48) => serializer.serialize_str("SpringGreen1"), - Color::Byte(49) => serializer.serialize_str("MediumSpringGreen"), - Color::Byte(50) => serializer.serialize_str("Cyan2"), - Color::Byte(51) => serializer.serialize_str("Cyan1"), - Color::Byte(52) => serializer.serialize_str("DarkRed"), - Color::Byte(53) => serializer.serialize_str("DeepPink4"), - Color::Byte(54) => serializer.serialize_str("Purple4"), - Color::Byte(55) => serializer.serialize_str("Purple4"), - Color::Byte(56) => serializer.serialize_str("Purple3"), - Color::Byte(57) => serializer.serialize_str("BlueViolet"), - Color::Byte(58) => serializer.serialize_str("Orange4"), - Color::Byte(59) => serializer.serialize_str("Grey37"), - Color::Byte(60) => serializer.serialize_str("MediumPurple4"), - Color::Byte(61) => serializer.serialize_str("SlateBlue3"), - Color::Byte(62) => serializer.serialize_str("SlateBlue3"), - Color::Byte(63) => serializer.serialize_str("RoyalBlue1"), - Color::Byte(64) => serializer.serialize_str("Chartreuse4"), - Color::Byte(65) => serializer.serialize_str("DarkSeaGreen4"), - Color::Byte(66) => serializer.serialize_str("PaleTurquoise4"), - Color::Byte(67) => serializer.serialize_str("SteelBlue"), - Color::Byte(68) => serializer.serialize_str("SteelBlue3"), - Color::Byte(69) => serializer.serialize_str("CornflowerBlue"), - Color::Byte(70) => serializer.serialize_str("Chartreuse3"), - Color::Byte(71) => serializer.serialize_str("DarkSeaGreen4"), - Color::Byte(72) => serializer.serialize_str("CadetBlue"), - Color::Byte(73) => serializer.serialize_str("CadetBlue"), - Color::Byte(74) => serializer.serialize_str("SkyBlue3"), - Color::Byte(75) => serializer.serialize_str("SteelBlue1"), - Color::Byte(76) => serializer.serialize_str("Chartreuse3"), - Color::Byte(77) => serializer.serialize_str("PaleGreen3"), - Color::Byte(78) => serializer.serialize_str("SeaGreen3"), - Color::Byte(79) => serializer.serialize_str("Aquamarine3"), - Color::Byte(80) => serializer.serialize_str("MediumTurquoise"), - Color::Byte(81) => serializer.serialize_str("SteelBlue1"), - Color::Byte(82) => serializer.serialize_str("Chartreuse2"), - Color::Byte(83) => serializer.serialize_str("SeaGreen2"), - Color::Byte(84) => serializer.serialize_str("SeaGreen1"), - Color::Byte(85) => serializer.serialize_str("SeaGreen1"), - Color::Byte(86) => serializer.serialize_str("Aquamarine1"), - Color::Byte(87) => serializer.serialize_str("DarkSlateGray2"), - Color::Byte(88) => serializer.serialize_str("DarkRed"), - Color::Byte(89) => serializer.serialize_str("DeepPink4"), - Color::Byte(90) => serializer.serialize_str("DarkMagenta"), - Color::Byte(91) => serializer.serialize_str("DarkMagenta"), - Color::Byte(92) => serializer.serialize_str("DarkViolet"), - Color::Byte(93) => serializer.serialize_str("Purple"), - Color::Byte(94) => serializer.serialize_str("Orange4"), - Color::Byte(95) => serializer.serialize_str("LightPink4"), - Color::Byte(96) => serializer.serialize_str("Plum4"), - Color::Byte(97) => serializer.serialize_str("MediumPurple3"), - Color::Byte(98) => serializer.serialize_str("MediumPurple3"), - Color::Byte(99) => serializer.serialize_str("SlateBlue1"), - Color::Byte(100) => serializer.serialize_str("Yellow4"), - Color::Byte(101) => serializer.serialize_str("Wheat4"), - Color::Byte(102) => serializer.serialize_str("Grey53"), - Color::Byte(103) => serializer.serialize_str("LightSlateGrey"), - Color::Byte(104) => serializer.serialize_str("MediumPurple"), - Color::Byte(105) => serializer.serialize_str("LightSlateBlue"), - Color::Byte(106) => serializer.serialize_str("Yellow4"), - Color::Byte(107) => serializer.serialize_str("DarkOliveGreen3"), - Color::Byte(108) => serializer.serialize_str("DarkSeaGreen"), - Color::Byte(109) => serializer.serialize_str("LightSkyBlue3"), - Color::Byte(110) => serializer.serialize_str("LightSkyBlue3"), - Color::Byte(111) => serializer.serialize_str("SkyBlue2"), - Color::Byte(112) => serializer.serialize_str("Chartreuse2"), - Color::Byte(113) => serializer.serialize_str("DarkOliveGreen3"), - Color::Byte(114) => serializer.serialize_str("PaleGreen3"), - Color::Byte(115) => serializer.serialize_str("DarkSeaGreen3"), - Color::Byte(116) => serializer.serialize_str("DarkSlateGray3"), - Color::Byte(117) => serializer.serialize_str("SkyBlue1"), - Color::Byte(118) => serializer.serialize_str("Chartreuse1"), - Color::Byte(119) => serializer.serialize_str("LightGreen"), - Color::Byte(120) => serializer.serialize_str("LightGreen"), - Color::Byte(121) => serializer.serialize_str("PaleGreen1"), - Color::Byte(122) => serializer.serialize_str("Aquamarine1"), - Color::Byte(123) => serializer.serialize_str("DarkSlateGray1"), - Color::Byte(124) => serializer.serialize_str("Red3"), - Color::Byte(125) => serializer.serialize_str("DeepPink4"), - Color::Byte(126) => serializer.serialize_str("MediumVioletRed"), - Color::Byte(127) => serializer.serialize_str("Magenta3"), - Color::Byte(128) => serializer.serialize_str("DarkViolet"), - Color::Byte(129) => serializer.serialize_str("Purple"), - Color::Byte(130) => serializer.serialize_str("DarkOrange3"), - Color::Byte(131) => serializer.serialize_str("IndianRed"), - Color::Byte(132) => serializer.serialize_str("HotPink3"), - Color::Byte(133) => serializer.serialize_str("MediumOrchid3"), - Color::Byte(134) => serializer.serialize_str("MediumOrchid"), - Color::Byte(135) => serializer.serialize_str("MediumPurple2"), - Color::Byte(136) => serializer.serialize_str("DarkGoldenrod"), - Color::Byte(137) => serializer.serialize_str("LightSalmon3"), - Color::Byte(138) => serializer.serialize_str("RosyBrown"), - Color::Byte(139) => serializer.serialize_str("Grey63"), - Color::Byte(140) => serializer.serialize_str("MediumPurple2"), - Color::Byte(141) => serializer.serialize_str("MediumPurple1"), - Color::Byte(142) => serializer.serialize_str("Gold3"), - Color::Byte(143) => serializer.serialize_str("DarkKhaki"), - Color::Byte(144) => serializer.serialize_str("NavajoWhite3"), - Color::Byte(145) => serializer.serialize_str("Grey69"), - Color::Byte(146) => serializer.serialize_str("LightSteelBlue3"), - Color::Byte(147) => serializer.serialize_str("LightSteelBlue"), - Color::Byte(148) => serializer.serialize_str("Yellow3"), - Color::Byte(149) => serializer.serialize_str("DarkOliveGreen3"), - Color::Byte(150) => serializer.serialize_str("DarkSeaGreen3"), - Color::Byte(151) => serializer.serialize_str("DarkSeaGreen2"), - Color::Byte(152) => serializer.serialize_str("LightCyan3"), - Color::Byte(153) => serializer.serialize_str("LightSkyBlue1"), - Color::Byte(154) => serializer.serialize_str("GreenYellow"), - Color::Byte(155) => serializer.serialize_str("DarkOliveGreen2"), - Color::Byte(156) => serializer.serialize_str("PaleGreen1"), - Color::Byte(157) => serializer.serialize_str("DarkSeaGreen2"), - Color::Byte(158) => serializer.serialize_str("DarkSeaGreen1"), - Color::Byte(159) => serializer.serialize_str("PaleTurquoise1"), - Color::Byte(160) => serializer.serialize_str("Red3"), - Color::Byte(161) => serializer.serialize_str("DeepPink3"), - Color::Byte(162) => serializer.serialize_str("DeepPink3"), - Color::Byte(163) => serializer.serialize_str("Magenta3"), - Color::Byte(164) => serializer.serialize_str("Magenta3"), - Color::Byte(165) => serializer.serialize_str("Magenta2"), - Color::Byte(166) => serializer.serialize_str("DarkOrange3"), - Color::Byte(167) => serializer.serialize_str("IndianRed"), - Color::Byte(168) => serializer.serialize_str("HotPink3"), - Color::Byte(169) => serializer.serialize_str("HotPink2"), - Color::Byte(170) => serializer.serialize_str("Orchid"), - Color::Byte(171) => serializer.serialize_str("MediumOrchid1"), - Color::Byte(172) => serializer.serialize_str("Orange3"), - Color::Byte(173) => serializer.serialize_str("LightSalmon3"), - Color::Byte(174) => serializer.serialize_str("LightPink3"), - Color::Byte(175) => serializer.serialize_str("Pink3"), - Color::Byte(176) => serializer.serialize_str("Plum3"), - Color::Byte(177) => serializer.serialize_str("Violet"), - Color::Byte(178) => serializer.serialize_str("Gold3"), - Color::Byte(179) => serializer.serialize_str("LightGoldenrod3"), - Color::Byte(180) => serializer.serialize_str("Tan"), - Color::Byte(181) => serializer.serialize_str("MistyRose3"), - Color::Byte(182) => serializer.serialize_str("Thistle3"), - Color::Byte(183) => serializer.serialize_str("Plum2"), - Color::Byte(184) => serializer.serialize_str("Yellow3"), - Color::Byte(185) => serializer.serialize_str("Khaki3"), - Color::Byte(186) => serializer.serialize_str("LightGoldenrod2"), - Color::Byte(187) => serializer.serialize_str("LightYellow3"), - Color::Byte(188) => serializer.serialize_str("Grey84"), - Color::Byte(189) => serializer.serialize_str("LightSteelBlue1"), - Color::Byte(190) => serializer.serialize_str("Yellow2"), - Color::Byte(191) => serializer.serialize_str("DarkOliveGreen1"), - Color::Byte(192) => serializer.serialize_str("DarkOliveGreen1"), - Color::Byte(193) => serializer.serialize_str("DarkSeaGreen1"), - Color::Byte(194) => serializer.serialize_str("Honeydew2"), - Color::Byte(195) => serializer.serialize_str("LightCyan1"), - Color::Byte(196) => serializer.serialize_str("Red1"), - Color::Byte(197) => serializer.serialize_str("DeepPink2"), - Color::Byte(198) => serializer.serialize_str("DeepPink1"), - Color::Byte(199) => serializer.serialize_str("DeepPink1"), - Color::Byte(200) => serializer.serialize_str("Magenta2"), - Color::Byte(201) => serializer.serialize_str("Magenta1"), - Color::Byte(202) => serializer.serialize_str("OrangeRed1"), - Color::Byte(203) => serializer.serialize_str("IndianRed1"), - Color::Byte(204) => serializer.serialize_str("IndianRed1"), - Color::Byte(205) => serializer.serialize_str("HotPink"), - Color::Byte(206) => serializer.serialize_str("HotPink"), - Color::Byte(207) => serializer.serialize_str("MediumOrchid1"), - Color::Byte(208) => serializer.serialize_str("DarkOrange"), - Color::Byte(209) => serializer.serialize_str("Salmon1"), - Color::Byte(210) => serializer.serialize_str("LightCoral"), - Color::Byte(211) => serializer.serialize_str("PaleVioletRed1"), - Color::Byte(212) => serializer.serialize_str("Orchid2"), - Color::Byte(213) => serializer.serialize_str("Orchid1"), - Color::Byte(214) => serializer.serialize_str("Orange1"), - Color::Byte(215) => serializer.serialize_str("SandyBrown"), - Color::Byte(216) => serializer.serialize_str("LightSalmon1"), - Color::Byte(217) => serializer.serialize_str("LightPink1"), - Color::Byte(218) => serializer.serialize_str("Pink1"), - Color::Byte(219) => serializer.serialize_str("Plum1"), - Color::Byte(220) => serializer.serialize_str("Gold1"), - Color::Byte(221) => serializer.serialize_str("LightGoldenrod2"), - Color::Byte(222) => serializer.serialize_str("LightGoldenrod2"), - Color::Byte(223) => serializer.serialize_str("NavajoWhite1"), - Color::Byte(224) => serializer.serialize_str("MistyRose1"), - Color::Byte(225) => serializer.serialize_str("Thistle1"), - Color::Byte(226) => serializer.serialize_str("Yellow1"), - Color::Byte(227) => serializer.serialize_str("LightGoldenrod1"), - Color::Byte(228) => serializer.serialize_str("Khaki1"), - Color::Byte(229) => serializer.serialize_str("Wheat1"), - Color::Byte(230) => serializer.serialize_str("Cornsilk1"), - Color::Byte(231) => serializer.serialize_str("Grey100"), - Color::Byte(232) => serializer.serialize_str("Grey3"), - Color::Byte(233) => serializer.serialize_str("Grey7"), - Color::Byte(234) => serializer.serialize_str("Grey11"), - Color::Byte(235) => serializer.serialize_str("Grey15"), - Color::Byte(236) => serializer.serialize_str("Grey19"), - Color::Byte(237) => serializer.serialize_str("Grey23"), - Color::Byte(238) => serializer.serialize_str("Grey27"), - Color::Byte(239) => serializer.serialize_str("Grey30"), - Color::Byte(240) => serializer.serialize_str("Grey35"), - Color::Byte(241) => serializer.serialize_str("Grey39"), - Color::Byte(242) => serializer.serialize_str("Grey42"), - Color::Byte(243) => serializer.serialize_str("Grey46"), - Color::Byte(244) => serializer.serialize_str("Grey50"), - Color::Byte(245) => serializer.serialize_str("Grey54"), - Color::Byte(246) => serializer.serialize_str("Grey58"), - Color::Byte(247) => serializer.serialize_str("Grey62"), - Color::Byte(248) => serializer.serialize_str("Grey66"), - Color::Byte(249) => serializer.serialize_str("Grey70"), - Color::Byte(250) => serializer.serialize_str("Grey74"), - Color::Byte(251) => serializer.serialize_str("Grey78"), - Color::Byte(252) => serializer.serialize_str("Grey82"), - Color::Byte(253) => serializer.serialize_str("Grey85"), - Color::Byte(254) => serializer.serialize_str("Grey89"), - Color::Byte(255) => serializer.serialize_str("Grey93"), - Color::Rgb(r, g, b) => { + Self::Black | Self::Byte(0) => serializer.serialize_str("Black"), + Self::Byte(1) => serializer.serialize_str("Maroon"), + Self::Green | Self::Byte(2) => serializer.serialize_str("Green"), + Self::Byte(3) => serializer.serialize_str("Olive"), + Self::Byte(4) => serializer.serialize_str("Navy"), + Self::Byte(5) | Self::Magenta => serializer.serialize_str("Purple"), + Self::Byte(6) | Self::Cyan => serializer.serialize_str("Teal"), + Self::Byte(7) => serializer.serialize_str("Silver"), + Self::Byte(8) => serializer.serialize_str("Grey"), + Self::Red | Self::Byte(9) => serializer.serialize_str("Red"), + Self::Byte(10) => serializer.serialize_str("Lime"), + Self::Yellow | Self::Byte(11) => serializer.serialize_str("Yellow"), + Self::Blue | Self::Byte(12) => serializer.serialize_str("Blue"), + Self::Byte(13) => serializer.serialize_str("Fuchsia"), + Self::Byte(14) => serializer.serialize_str("Aqua"), + Self::White | Self::Byte(15) => serializer.serialize_str("White"), + Self::Byte(16) => serializer.serialize_str("Grey0"), + Self::Byte(17) => serializer.serialize_str("NavyBlue"), + Self::Byte(18) => serializer.serialize_str("DarkBlue"), + Self::Byte(19) => serializer.serialize_str("Blue3"), + Self::Byte(20) => serializer.serialize_str("Blue3"), + Self::Byte(21) => serializer.serialize_str("Blue1"), + Self::Byte(22) => serializer.serialize_str("DarkGreen"), + Self::Byte(23) => serializer.serialize_str("DeepSkyBlue4"), + Self::Byte(24) => serializer.serialize_str("DeepSkyBlue4"), + Self::Byte(25) => serializer.serialize_str("DeepSkyBlue4"), + Self::Byte(26) => serializer.serialize_str("DodgerBlue3"), + Self::Byte(27) => serializer.serialize_str("DodgerBlue2"), + Self::Byte(28) => serializer.serialize_str("Green4"), + Self::Byte(29) => serializer.serialize_str("SpringGreen4"), + Self::Byte(30) => serializer.serialize_str("Turquoise4"), + Self::Byte(31) => serializer.serialize_str("DeepSkyBlue3"), + Self::Byte(32) => serializer.serialize_str("DeepSkyBlue3"), + Self::Byte(33) => serializer.serialize_str("DodgerBlue1"), + Self::Byte(34) => serializer.serialize_str("Green3"), + Self::Byte(35) => serializer.serialize_str("SpringGreen3"), + Self::Byte(36) => serializer.serialize_str("DarkCyan"), + Self::Byte(37) => serializer.serialize_str("LightSeaGreen"), + Self::Byte(38) => serializer.serialize_str("DeepSkyBlue2"), + Self::Byte(39) => serializer.serialize_str("DeepSkyBlue1"), + Self::Byte(40) => serializer.serialize_str("Green3"), + Self::Byte(41) => serializer.serialize_str("SpringGreen3"), + Self::Byte(42) => serializer.serialize_str("SpringGreen2"), + Self::Byte(43) => serializer.serialize_str("Cyan3"), + Self::Byte(44) => serializer.serialize_str("DarkTurquoise"), + Self::Byte(45) => serializer.serialize_str("Turquoise2"), + Self::Byte(46) => serializer.serialize_str("Green1"), + Self::Byte(47) => serializer.serialize_str("SpringGreen2"), + Self::Byte(48) => serializer.serialize_str("SpringGreen1"), + Self::Byte(49) => serializer.serialize_str("MediumSpringGreen"), + Self::Byte(50) => serializer.serialize_str("Cyan2"), + Self::Byte(51) => serializer.serialize_str("Cyan1"), + Self::Byte(52) => serializer.serialize_str("DarkRed"), + Self::Byte(53) => serializer.serialize_str("DeepPink4"), + Self::Byte(54) => serializer.serialize_str("Purple4"), + Self::Byte(55) => serializer.serialize_str("Purple4"), + Self::Byte(56) => serializer.serialize_str("Purple3"), + Self::Byte(57) => serializer.serialize_str("BlueViolet"), + Self::Byte(58) => serializer.serialize_str("Orange4"), + Self::Byte(59) => serializer.serialize_str("Grey37"), + Self::Byte(60) => serializer.serialize_str("MediumPurple4"), + Self::Byte(61) => serializer.serialize_str("SlateBlue3"), + Self::Byte(62) => serializer.serialize_str("SlateBlue3"), + Self::Byte(63) => serializer.serialize_str("RoyalBlue1"), + Self::Byte(64) => serializer.serialize_str("Chartreuse4"), + Self::Byte(65) => serializer.serialize_str("DarkSeaGreen4"), + Self::Byte(66) => serializer.serialize_str("PaleTurquoise4"), + Self::Byte(67) => serializer.serialize_str("SteelBlue"), + Self::Byte(68) => serializer.serialize_str("SteelBlue3"), + Self::Byte(69) => serializer.serialize_str("CornflowerBlue"), + Self::Byte(70) => serializer.serialize_str("Chartreuse3"), + Self::Byte(71) => serializer.serialize_str("DarkSeaGreen4"), + Self::Byte(72) => serializer.serialize_str("CadetBlue"), + Self::Byte(73) => serializer.serialize_str("CadetBlue"), + Self::Byte(74) => serializer.serialize_str("SkyBlue3"), + Self::Byte(75) => serializer.serialize_str("SteelBlue1"), + Self::Byte(76) => serializer.serialize_str("Chartreuse3"), + Self::Byte(77) => serializer.serialize_str("PaleGreen3"), + Self::Byte(78) => serializer.serialize_str("SeaGreen3"), + Self::Byte(79) => serializer.serialize_str("Aquamarine3"), + Self::Byte(80) => serializer.serialize_str("MediumTurquoise"), + Self::Byte(81) => serializer.serialize_str("SteelBlue1"), + Self::Byte(82) => serializer.serialize_str("Chartreuse2"), + Self::Byte(83) => serializer.serialize_str("SeaGreen2"), + Self::Byte(84) => serializer.serialize_str("SeaGreen1"), + Self::Byte(85) => serializer.serialize_str("SeaGreen1"), + Self::Byte(86) => serializer.serialize_str("Aquamarine1"), + Self::Byte(87) => serializer.serialize_str("DarkSlateGray2"), + Self::Byte(88) => serializer.serialize_str("DarkRed"), + Self::Byte(89) => serializer.serialize_str("DeepPink4"), + Self::Byte(90) => serializer.serialize_str("DarkMagenta"), + Self::Byte(91) => serializer.serialize_str("DarkMagenta"), + Self::Byte(92) => serializer.serialize_str("DarkViolet"), + Self::Byte(93) => serializer.serialize_str("Purple"), + Self::Byte(94) => serializer.serialize_str("Orange4"), + Self::Byte(95) => serializer.serialize_str("LightPink4"), + Self::Byte(96) => serializer.serialize_str("Plum4"), + Self::Byte(97) => serializer.serialize_str("MediumPurple3"), + Self::Byte(98) => serializer.serialize_str("MediumPurple3"), + Self::Byte(99) => serializer.serialize_str("SlateBlue1"), + Self::Byte(100) => serializer.serialize_str("Yellow4"), + Self::Byte(101) => serializer.serialize_str("Wheat4"), + Self::Byte(102) => serializer.serialize_str("Grey53"), + Self::Byte(103) => serializer.serialize_str("LightSlateGrey"), + Self::Byte(104) => serializer.serialize_str("MediumPurple"), + Self::Byte(105) => serializer.serialize_str("LightSlateBlue"), + Self::Byte(106) => serializer.serialize_str("Yellow4"), + Self::Byte(107) => serializer.serialize_str("DarkOliveGreen3"), + Self::Byte(108) => serializer.serialize_str("DarkSeaGreen"), + Self::Byte(109) => serializer.serialize_str("LightSkyBlue3"), + Self::Byte(110) => serializer.serialize_str("LightSkyBlue3"), + Self::Byte(111) => serializer.serialize_str("SkyBlue2"), + Self::Byte(112) => serializer.serialize_str("Chartreuse2"), + Self::Byte(113) => serializer.serialize_str("DarkOliveGreen3"), + Self::Byte(114) => serializer.serialize_str("PaleGreen3"), + Self::Byte(115) => serializer.serialize_str("DarkSeaGreen3"), + Self::Byte(116) => serializer.serialize_str("DarkSlateGray3"), + Self::Byte(117) => serializer.serialize_str("SkyBlue1"), + Self::Byte(118) => serializer.serialize_str("Chartreuse1"), + Self::Byte(119) => serializer.serialize_str("LightGreen"), + Self::Byte(120) => serializer.serialize_str("LightGreen"), + Self::Byte(121) => serializer.serialize_str("PaleGreen1"), + Self::Byte(122) => serializer.serialize_str("Aquamarine1"), + Self::Byte(123) => serializer.serialize_str("DarkSlateGray1"), + Self::Byte(124) => serializer.serialize_str("Red3"), + Self::Byte(125) => serializer.serialize_str("DeepPink4"), + Self::Byte(126) => serializer.serialize_str("MediumVioletRed"), + Self::Byte(127) => serializer.serialize_str("Magenta3"), + Self::Byte(128) => serializer.serialize_str("DarkViolet"), + Self::Byte(129) => serializer.serialize_str("Purple"), + Self::Byte(130) => serializer.serialize_str("DarkOrange3"), + Self::Byte(131) => serializer.serialize_str("IndianRed"), + Self::Byte(132) => serializer.serialize_str("HotPink3"), + Self::Byte(133) => serializer.serialize_str("MediumOrchid3"), + Self::Byte(134) => serializer.serialize_str("MediumOrchid"), + Self::Byte(135) => serializer.serialize_str("MediumPurple2"), + Self::Byte(136) => serializer.serialize_str("DarkGoldenrod"), + Self::Byte(137) => serializer.serialize_str("LightSalmon3"), + Self::Byte(138) => serializer.serialize_str("RosyBrown"), + Self::Byte(139) => serializer.serialize_str("Grey63"), + Self::Byte(140) => serializer.serialize_str("MediumPurple2"), + Self::Byte(141) => serializer.serialize_str("MediumPurple1"), + Self::Byte(142) => serializer.serialize_str("Gold3"), + Self::Byte(143) => serializer.serialize_str("DarkKhaki"), + Self::Byte(144) => serializer.serialize_str("NavajoWhite3"), + Self::Byte(145) => serializer.serialize_str("Grey69"), + Self::Byte(146) => serializer.serialize_str("LightSteelBlue3"), + Self::Byte(147) => serializer.serialize_str("LightSteelBlue"), + Self::Byte(148) => serializer.serialize_str("Yellow3"), + Self::Byte(149) => serializer.serialize_str("DarkOliveGreen3"), + Self::Byte(150) => serializer.serialize_str("DarkSeaGreen3"), + Self::Byte(151) => serializer.serialize_str("DarkSeaGreen2"), + Self::Byte(152) => serializer.serialize_str("LightCyan3"), + Self::Byte(153) => serializer.serialize_str("LightSkyBlue1"), + Self::Byte(154) => serializer.serialize_str("GreenYellow"), + Self::Byte(155) => serializer.serialize_str("DarkOliveGreen2"), + Self::Byte(156) => serializer.serialize_str("PaleGreen1"), + Self::Byte(157) => serializer.serialize_str("DarkSeaGreen2"), + Self::Byte(158) => serializer.serialize_str("DarkSeaGreen1"), + Self::Byte(159) => serializer.serialize_str("PaleTurquoise1"), + Self::Byte(160) => serializer.serialize_str("Red3"), + Self::Byte(161) => serializer.serialize_str("DeepPink3"), + Self::Byte(162) => serializer.serialize_str("DeepPink3"), + Self::Byte(163) => serializer.serialize_str("Magenta3"), + Self::Byte(164) => serializer.serialize_str("Magenta3"), + Self::Byte(165) => serializer.serialize_str("Magenta2"), + Self::Byte(166) => serializer.serialize_str("DarkOrange3"), + Self::Byte(167) => serializer.serialize_str("IndianRed"), + Self::Byte(168) => serializer.serialize_str("HotPink3"), + Self::Byte(169) => serializer.serialize_str("HotPink2"), + Self::Byte(170) => serializer.serialize_str("Orchid"), + Self::Byte(171) => serializer.serialize_str("MediumOrchid1"), + Self::Byte(172) => serializer.serialize_str("Orange3"), + Self::Byte(173) => serializer.serialize_str("LightSalmon3"), + Self::Byte(174) => serializer.serialize_str("LightPink3"), + Self::Byte(175) => serializer.serialize_str("Pink3"), + Self::Byte(176) => serializer.serialize_str("Plum3"), + Self::Byte(177) => serializer.serialize_str("Violet"), + Self::Byte(178) => serializer.serialize_str("Gold3"), + Self::Byte(179) => serializer.serialize_str("LightGoldenrod3"), + Self::Byte(180) => serializer.serialize_str("Tan"), + Self::Byte(181) => serializer.serialize_str("MistyRose3"), + Self::Byte(182) => serializer.serialize_str("Thistle3"), + Self::Byte(183) => serializer.serialize_str("Plum2"), + Self::Byte(184) => serializer.serialize_str("Yellow3"), + Self::Byte(185) => serializer.serialize_str("Khaki3"), + Self::Byte(186) => serializer.serialize_str("LightGoldenrod2"), + Self::Byte(187) => serializer.serialize_str("LightYellow3"), + Self::Byte(188) => serializer.serialize_str("Grey84"), + Self::Byte(189) => serializer.serialize_str("LightSteelBlue1"), + Self::Byte(190) => serializer.serialize_str("Yellow2"), + Self::Byte(191) => serializer.serialize_str("DarkOliveGreen1"), + Self::Byte(192) => serializer.serialize_str("DarkOliveGreen1"), + Self::Byte(193) => serializer.serialize_str("DarkSeaGreen1"), + Self::Byte(194) => serializer.serialize_str("Honeydew2"), + Self::Byte(195) => serializer.serialize_str("LightCyan1"), + Self::Byte(196) => serializer.serialize_str("Red1"), + Self::Byte(197) => serializer.serialize_str("DeepPink2"), + Self::Byte(198) => serializer.serialize_str("DeepPink1"), + Self::Byte(199) => serializer.serialize_str("DeepPink1"), + Self::Byte(200) => serializer.serialize_str("Magenta2"), + Self::Byte(201) => serializer.serialize_str("Magenta1"), + Self::Byte(202) => serializer.serialize_str("OrangeRed1"), + Self::Byte(203) => serializer.serialize_str("IndianRed1"), + Self::Byte(204) => serializer.serialize_str("IndianRed1"), + Self::Byte(205) => serializer.serialize_str("HotPink"), + Self::Byte(206) => serializer.serialize_str("HotPink"), + Self::Byte(207) => serializer.serialize_str("MediumOrchid1"), + Self::Byte(208) => serializer.serialize_str("DarkOrange"), + Self::Byte(209) => serializer.serialize_str("Salmon1"), + Self::Byte(210) => serializer.serialize_str("LightCoral"), + Self::Byte(211) => serializer.serialize_str("PaleVioletRed1"), + Self::Byte(212) => serializer.serialize_str("Orchid2"), + Self::Byte(213) => serializer.serialize_str("Orchid1"), + Self::Byte(214) => serializer.serialize_str("Orange1"), + Self::Byte(215) => serializer.serialize_str("SandyBrown"), + Self::Byte(216) => serializer.serialize_str("LightSalmon1"), + Self::Byte(217) => serializer.serialize_str("LightPink1"), + Self::Byte(218) => serializer.serialize_str("Pink1"), + Self::Byte(219) => serializer.serialize_str("Plum1"), + Self::Byte(220) => serializer.serialize_str("Gold1"), + Self::Byte(221) => serializer.serialize_str("LightGoldenrod2"), + Self::Byte(222) => serializer.serialize_str("LightGoldenrod2"), + Self::Byte(223) => serializer.serialize_str("NavajoWhite1"), + Self::Byte(224) => serializer.serialize_str("MistyRose1"), + Self::Byte(225) => serializer.serialize_str("Thistle1"), + Self::Byte(226) => serializer.serialize_str("Yellow1"), + Self::Byte(227) => serializer.serialize_str("LightGoldenrod1"), + Self::Byte(228) => serializer.serialize_str("Khaki1"), + Self::Byte(229) => serializer.serialize_str("Wheat1"), + Self::Byte(230) => serializer.serialize_str("Cornsilk1"), + Self::Byte(231) => serializer.serialize_str("Grey100"), + Self::Byte(232) => serializer.serialize_str("Grey3"), + Self::Byte(233) => serializer.serialize_str("Grey7"), + Self::Byte(234) => serializer.serialize_str("Grey11"), + Self::Byte(235) => serializer.serialize_str("Grey15"), + Self::Byte(236) => serializer.serialize_str("Grey19"), + Self::Byte(237) => serializer.serialize_str("Grey23"), + Self::Byte(238) => serializer.serialize_str("Grey27"), + Self::Byte(239) => serializer.serialize_str("Grey30"), + Self::Byte(240) => serializer.serialize_str("Grey35"), + Self::Byte(241) => serializer.serialize_str("Grey39"), + Self::Byte(242) => serializer.serialize_str("Grey42"), + Self::Byte(243) => serializer.serialize_str("Grey46"), + Self::Byte(244) => serializer.serialize_str("Grey50"), + Self::Byte(245) => serializer.serialize_str("Grey54"), + Self::Byte(246) => serializer.serialize_str("Grey58"), + Self::Byte(247) => serializer.serialize_str("Grey62"), + Self::Byte(248) => serializer.serialize_str("Grey66"), + Self::Byte(249) => serializer.serialize_str("Grey70"), + Self::Byte(250) => serializer.serialize_str("Grey74"), + Self::Byte(251) => serializer.serialize_str("Grey78"), + Self::Byte(252) => serializer.serialize_str("Grey82"), + Self::Byte(253) => serializer.serialize_str("Grey85"), + Self::Byte(254) => serializer.serialize_str("Grey89"), + Self::Byte(255) => serializer.serialize_str("Grey93"), + Self::Rgb(r, g, b) => { serializer.serialize_str(&format!("#{:02x}{:02x}{:02x}", r, g, b)) } - Color::Default => serializer.serialize_str("Default"), + Self::Default => serializer.serialize_str("Default"), } } } @@ -762,261 +762,261 @@ pub mod aliases { use super::Color; impl Color { - pub const BLACK: Color = Color::Black; - pub const MAROON: Color = Color::Byte(1); - pub const GREEN: Color = Color::Green; - pub const OLIVE: Color = Color::Byte(3); - pub const NAVY: Color = Color::Byte(4); - pub const PURPLE: Color = Color::Magenta; - pub const TEAL: Color = Color::Cyan; - pub const SILVER: Color = Color::Byte(7); - pub const GREY: Color = Color::Byte(8); - pub const RED: Color = Color::Byte(9); - pub const LIME: Color = Color::Byte(10); - pub const YELLOW: Color = Color::Byte(11); - pub const BLUE: Color = Color::Byte(12); - pub const FUCHSIA: Color = Color::Byte(13); - pub const AQUA: Color = Color::Byte(14); - pub const WHITE: Color = Color::Byte(15); - pub const GREY0: Color = Color::Byte(16); - pub const NAVYBLUE: Color = Color::Byte(17); - pub const DARKBLUE: Color = Color::Byte(18); - pub const BLUE3: Color = Color::Byte(19); - pub const BLUE3_: Color = Color::Byte(20); - pub const BLUE1: Color = Color::Byte(21); - pub const DARKGREEN: Color = Color::Byte(22); - pub const DEEPSKYBLUE4: Color = Color::Byte(23); - pub const DEEPSKYBLUE4_: Color = Color::Byte(24); - pub const DEEPSKYBLUE4__: Color = Color::Byte(25); - pub const DODGERBLUE3: Color = Color::Byte(26); - pub const DODGERBLUE2: Color = Color::Byte(27); - pub const GREEN4: Color = Color::Byte(28); - pub const SPRINGGREEN4: Color = Color::Byte(29); - pub const TURQUOISE4: Color = Color::Byte(30); - pub const DEEPSKYBLUE3: Color = Color::Byte(31); - pub const DEEPSKYBLUE3_: Color = Color::Byte(32); - pub const DODGERBLUE1: Color = Color::Byte(33); - pub const GREEN3: Color = Color::Byte(34); - pub const SPRINGGREEN3: Color = Color::Byte(35); - pub const DARKCYAN: Color = Color::Byte(36); - pub const LIGHTSEAGREEN: Color = Color::Byte(37); - pub const DEEPSKYBLUE2: Color = Color::Byte(38); - pub const DEEPSKYBLUE1: Color = Color::Byte(39); - pub const GREEN3_: Color = Color::Byte(40); - pub const SPRINGGREEN3_: Color = Color::Byte(41); - pub const SPRINGGREEN2: Color = Color::Byte(42); - pub const CYAN3: Color = Color::Byte(43); - pub const DARKTURQUOISE: Color = Color::Byte(44); - pub const TURQUOISE2: Color = Color::Byte(45); - pub const GREEN1: Color = Color::Byte(46); - pub const SPRINGGREEN2_: Color = Color::Byte(47); - pub const SPRINGGREEN1: Color = Color::Byte(48); - pub const MEDIUMSPRINGGREEN: Color = Color::Byte(49); - pub const CYAN2: Color = Color::Byte(50); - pub const CYAN1: Color = Color::Byte(51); - pub const DARKRED: Color = Color::Byte(52); - pub const DEEPPINK4: Color = Color::Byte(53); - pub const PURPLE4: Color = Color::Byte(54); - pub const PURPLE4_: Color = Color::Byte(55); - pub const PURPLE3: Color = Color::Byte(56); - pub const BLUEVIOLET: Color = Color::Byte(57); - pub const ORANGE4: Color = Color::Byte(58); - pub const GREY37: Color = Color::Byte(59); - pub const MEDIUMPURPLE4: Color = Color::Byte(60); - pub const SLATEBLUE3: Color = Color::Byte(61); - pub const SLATEBLUE3_: Color = Color::Byte(62); - pub const ROYALBLUE1: Color = Color::Byte(63); - pub const CHARTREUSE4: Color = Color::Byte(64); - pub const DARKSEAGREEN4: Color = Color::Byte(65); - pub const PALETURQUOISE4: Color = Color::Byte(66); - pub const STEELBLUE: Color = Color::Byte(67); - pub const STEELBLUE3: Color = Color::Byte(68); - pub const CORNFLOWERBLUE: Color = Color::Byte(69); - pub const CHARTREUSE3: Color = Color::Byte(70); - pub const DARKSEAGREEN4_: Color = Color::Byte(71); - pub const CADETBLUE: Color = Color::Byte(72); - pub const CADETBLUE_: Color = Color::Byte(73); - pub const SKYBLUE3: Color = Color::Byte(74); - pub const STEELBLUE1: Color = Color::Byte(75); - pub const CHARTREUSE3_: Color = Color::Byte(76); - pub const PALEGREEN3: Color = Color::Byte(77); - pub const SEAGREEN3: Color = Color::Byte(78); - pub const AQUAMARINE3: Color = Color::Byte(79); - pub const MEDIUMTURQUOISE: Color = Color::Byte(80); - pub const STEELBLUE1_: Color = Color::Byte(81); - pub const CHARTREUSE2: Color = Color::Byte(82); - pub const SEAGREEN2: Color = Color::Byte(83); - pub const SEAGREEN1: Color = Color::Byte(84); - pub const SEAGREEN1_: Color = Color::Byte(85); - pub const AQUAMARINE1: Color = Color::Byte(86); - pub const DARKSLATEGRAY2: Color = Color::Byte(87); - pub const DARKRED_: Color = Color::Byte(88); - pub const DEEPPINK4_: Color = Color::Byte(89); - pub const DARKMAGENTA: Color = Color::Byte(90); - pub const DARKMAGENTA_: Color = Color::Byte(91); - pub const DARKVIOLET: Color = Color::Byte(92); - pub const PURPLE_: Color = Color::Byte(93); - pub const ORANGE4_: Color = Color::Byte(94); - pub const LIGHTPINK4: Color = Color::Byte(95); - pub const PLUM4: Color = Color::Byte(96); - pub const MEDIUMPURPLE3: Color = Color::Byte(97); - pub const MEDIUMPURPLE3_: Color = Color::Byte(98); - pub const SLATEBLUE1: Color = Color::Byte(99); - pub const YELLOW4: Color = Color::Byte(100); - pub const WHEAT4: Color = Color::Byte(101); - pub const GREY53: Color = Color::Byte(102); - pub const LIGHTSLATEGREY: Color = Color::Byte(103); - pub const MEDIUMPURPLE: Color = Color::Byte(104); - pub const LIGHTSLATEBLUE: Color = Color::Byte(105); - pub const YELLOW4_: Color = Color::Byte(106); - pub const DARKOLIVEGREEN3: Color = Color::Byte(107); - pub const DARKSEAGREEN: Color = Color::Byte(108); - pub const LIGHTSKYBLUE3: Color = Color::Byte(109); - pub const LIGHTSKYBLUE3_: Color = Color::Byte(110); - pub const SKYBLUE2: Color = Color::Byte(111); - pub const CHARTREUSE2_: Color = Color::Byte(112); - pub const DARKOLIVEGREEN3_: Color = Color::Byte(113); - pub const PALEGREEN3_: Color = Color::Byte(114); - pub const DARKSEAGREEN3: Color = Color::Byte(115); - pub const DARKSLATEGRAY3: Color = Color::Byte(116); - pub const SKYBLUE1: Color = Color::Byte(117); - pub const CHARTREUSE1: Color = Color::Byte(118); - pub const LIGHTGREEN: Color = Color::Byte(119); - pub const LIGHTGREEN_: Color = Color::Byte(120); - pub const PALEGREEN1: Color = Color::Byte(121); - pub const AQUAMARINE1_: Color = Color::Byte(122); - pub const DARKSLATEGRAY1: Color = Color::Byte(123); - pub const RED3: Color = Color::Byte(124); - pub const DEEPPINK4__: Color = Color::Byte(125); - pub const MEDIUMVIOLETRED: Color = Color::Byte(126); - pub const MAGENTA3: Color = Color::Byte(127); - pub const DARKVIOLET_: Color = Color::Byte(128); - pub const PURPLE__: Color = Color::Byte(129); - pub const DARKORANGE3: Color = Color::Byte(130); - pub const INDIANRED: Color = Color::Byte(131); - pub const HOTPINK3: Color = Color::Byte(132); - pub const MEDIUMORCHID3: Color = Color::Byte(133); - pub const MEDIUMORCHID: Color = Color::Byte(134); - pub const MEDIUMPURPLE2: Color = Color::Byte(135); - pub const DARKGOLDENROD: Color = Color::Byte(136); - pub const LIGHTSALMON3: Color = Color::Byte(137); - pub const ROSYBROWN: Color = Color::Byte(138); - pub const GREY63: Color = Color::Byte(139); - pub const MEDIUMPURPLE2_: Color = Color::Byte(140); - pub const MEDIUMPURPLE1: Color = Color::Byte(141); - pub const GOLD3: Color = Color::Byte(142); - pub const DARKKHAKI: Color = Color::Byte(143); - pub const NAVAJOWHITE3: Color = Color::Byte(144); - pub const GREY69: Color = Color::Byte(145); - pub const LIGHTSTEELBLUE3: Color = Color::Byte(146); - pub const LIGHTSTEELBLUE: Color = Color::Byte(147); - pub const YELLOW3: Color = Color::Byte(148); - pub const DARKOLIVEGREEN3__: Color = Color::Byte(149); - pub const DARKSEAGREEN3_: Color = Color::Byte(150); - pub const DARKSEAGREEN2: Color = Color::Byte(151); - pub const LIGHTCYAN3: Color = Color::Byte(152); - pub const LIGHTSKYBLUE1: Color = Color::Byte(153); - pub const GREENYELLOW: Color = Color::Byte(154); - pub const DARKOLIVEGREEN2: Color = Color::Byte(155); - pub const PALEGREEN1_: Color = Color::Byte(156); - pub const DARKSEAGREEN2_: Color = Color::Byte(157); - pub const DARKSEAGREEN1: Color = Color::Byte(158); - pub const PALETURQUOISE1: Color = Color::Byte(159); - pub const RED3_: Color = Color::Byte(160); - pub const DEEPPINK3: Color = Color::Byte(161); - pub const DEEPPINK3_: Color = Color::Byte(162); - pub const MAGENTA3_: Color = Color::Byte(163); - pub const MAGENTA3__: Color = Color::Byte(164); - pub const MAGENTA2: Color = Color::Byte(165); - pub const DARKORANGE3_: Color = Color::Byte(166); - pub const INDIANRED_: Color = Color::Byte(167); - pub const HOTPINK3_: Color = Color::Byte(168); - pub const HOTPINK2: Color = Color::Byte(169); - pub const ORCHID: Color = Color::Byte(170); - pub const MEDIUMORCHID1: Color = Color::Byte(171); - pub const ORANGE3: Color = Color::Byte(172); - pub const LIGHTSALMON3_: Color = Color::Byte(173); - pub const LIGHTPINK3: Color = Color::Byte(174); - pub const PINK3: Color = Color::Byte(175); - pub const PLUM3: Color = Color::Byte(176); - pub const VIOLET: Color = Color::Byte(177); - pub const GOLD3_: Color = Color::Byte(178); - pub const LIGHTGOLDENROD3: Color = Color::Byte(179); - pub const TAN: Color = Color::Byte(180); - pub const MISTYROSE3: Color = Color::Byte(181); - pub const THISTLE3: Color = Color::Byte(182); - pub const PLUM2: Color = Color::Byte(183); - pub const YELLOW3_: Color = Color::Byte(184); - pub const KHAKI3: Color = Color::Byte(185); - pub const LIGHTGOLDENROD2: Color = Color::Byte(186); - pub const LIGHTYELLOW3: Color = Color::Byte(187); - pub const GREY84: Color = Color::Byte(188); - pub const LIGHTSTEELBLUE1: Color = Color::Byte(189); - pub const YELLOW2: Color = Color::Byte(190); - pub const DARKOLIVEGREEN1: Color = Color::Byte(191); - pub const DARKOLIVEGREEN1_: Color = Color::Byte(192); - pub const DARKSEAGREEN1_: Color = Color::Byte(193); - pub const HONEYDEW2: Color = Color::Byte(194); - pub const LIGHTCYAN1: Color = Color::Byte(195); - pub const RED1: Color = Color::Byte(196); - pub const DEEPPINK2: Color = Color::Byte(197); - pub const DEEPPINK1: Color = Color::Byte(198); - pub const DEEPPINK1_: Color = Color::Byte(199); - pub const MAGENTA2_: Color = Color::Byte(200); - pub const MAGENTA1: Color = Color::Byte(201); - pub const ORANGERED1: Color = Color::Byte(202); - pub const INDIANRED1: Color = Color::Byte(203); - pub const INDIANRED1_: Color = Color::Byte(204); - pub const HOTPINK: Color = Color::Byte(205); - pub const HOTPINK_: Color = Color::Byte(206); - pub const MEDIUMORCHID1_: Color = Color::Byte(207); - pub const DARKORANGE: Color = Color::Byte(208); - pub const SALMON1: Color = Color::Byte(209); - pub const LIGHTCORAL: Color = Color::Byte(210); - pub const PALEVIOLETRED1: Color = Color::Byte(211); - pub const ORCHID2: Color = Color::Byte(212); - pub const ORCHID1: Color = Color::Byte(213); - pub const ORANGE1: Color = Color::Byte(214); - pub const SANDYBROWN: Color = Color::Byte(215); - pub const LIGHTSALMON1: Color = Color::Byte(216); - pub const LIGHTPINK1: Color = Color::Byte(217); - pub const PINK1: Color = Color::Byte(218); - pub const PLUM1: Color = Color::Byte(219); - pub const GOLD1: Color = Color::Byte(220); - pub const LIGHTGOLDENROD2_: Color = Color::Byte(221); - pub const LIGHTGOLDENROD2__: Color = Color::Byte(222); - pub const NAVAJOWHITE1: Color = Color::Byte(223); - pub const MISTYROSE1: Color = Color::Byte(224); - pub const THISTLE1: Color = Color::Byte(225); - pub const YELLOW1: Color = Color::Byte(226); - pub const LIGHTGOLDENROD1: Color = Color::Byte(227); - pub const KHAKI1: Color = Color::Byte(228); - pub const WHEAT1: Color = Color::Byte(229); - pub const CORNSILK1: Color = Color::Byte(230); - pub const GREY100: Color = Color::Byte(231); - pub const GREY3: Color = Color::Byte(232); - pub const GREY7: Color = Color::Byte(233); - pub const GREY11: Color = Color::Byte(234); - pub const GREY15: Color = Color::Byte(235); - pub const GREY19: Color = Color::Byte(236); - pub const GREY23: Color = Color::Byte(237); - pub const GREY27: Color = Color::Byte(238); - pub const GREY30: Color = Color::Byte(239); - pub const GREY35: Color = Color::Byte(240); - pub const GREY39: Color = Color::Byte(241); - pub const GREY42: Color = Color::Byte(242); - pub const GREY46: Color = Color::Byte(243); - pub const GREY50: Color = Color::Byte(244); - pub const GREY54: Color = Color::Byte(245); - pub const GREY58: Color = Color::Byte(246); - pub const GREY62: Color = Color::Byte(247); - pub const GREY66: Color = Color::Byte(248); - pub const GREY70: Color = Color::Byte(249); - pub const GREY74: Color = Color::Byte(250); - pub const GREY78: Color = Color::Byte(251); - pub const GREY82: Color = Color::Byte(252); - pub const GREY85: Color = Color::Byte(253); - pub const GREY89: Color = Color::Byte(254); - pub const GREY93: Color = Color::Byte(255); + pub const BLACK: Self = Self::Black; + pub const MAROON: Self = Self::Byte(1); + pub const GREEN: Self = Self::Green; + pub const OLIVE: Self = Self::Byte(3); + pub const NAVY: Self = Self::Byte(4); + pub const PURPLE: Self = Self::Magenta; + pub const TEAL: Self = Self::Cyan; + pub const SILVER: Self = Self::Byte(7); + pub const GREY: Self = Self::Byte(8); + pub const RED: Self = Self::Byte(9); + pub const LIME: Self = Self::Byte(10); + pub const YELLOW: Self = Self::Byte(11); + pub const BLUE: Self = Self::Byte(12); + pub const FUCHSIA: Self = Self::Byte(13); + pub const AQUA: Self = Self::Byte(14); + pub const WHITE: Self = Self::Byte(15); + pub const GREY0: Self = Self::Byte(16); + pub const NAVYBLUE: Self = Self::Byte(17); + pub const DARKBLUE: Self = Self::Byte(18); + pub const BLUE3: Self = Self::Byte(19); + pub const BLUE3_: Self = Self::Byte(20); + pub const BLUE1: Self = Self::Byte(21); + pub const DARKGREEN: Self = Self::Byte(22); + pub const DEEPSKYBLUE4: Self = Self::Byte(23); + pub const DEEPSKYBLUE4_: Self = Self::Byte(24); + pub const DEEPSKYBLUE4__: Self = Self::Byte(25); + pub const DODGERBLUE3: Self = Self::Byte(26); + pub const DODGERBLUE2: Self = Self::Byte(27); + pub const GREEN4: Self = Self::Byte(28); + pub const SPRINGGREEN4: Self = Self::Byte(29); + pub const TURQUOISE4: Self = Self::Byte(30); + pub const DEEPSKYBLUE3: Self = Self::Byte(31); + pub const DEEPSKYBLUE3_: Self = Self::Byte(32); + pub const DODGERBLUE1: Self = Self::Byte(33); + pub const GREEN3: Self = Self::Byte(34); + pub const SPRINGGREEN3: Self = Self::Byte(35); + pub const DARKCYAN: Self = Self::Byte(36); + pub const LIGHTSEAGREEN: Self = Self::Byte(37); + pub const DEEPSKYBLUE2: Self = Self::Byte(38); + pub const DEEPSKYBLUE1: Self = Self::Byte(39); + pub const GREEN3_: Self = Self::Byte(40); + pub const SPRINGGREEN3_: Self = Self::Byte(41); + pub const SPRINGGREEN2: Self = Self::Byte(42); + pub const CYAN3: Self = Self::Byte(43); + pub const DARKTURQUOISE: Self = Self::Byte(44); + pub const TURQUOISE2: Self = Self::Byte(45); + pub const GREEN1: Self = Self::Byte(46); + pub const SPRINGGREEN2_: Self = Self::Byte(47); + pub const SPRINGGREEN1: Self = Self::Byte(48); + pub const MEDIUMSPRINGGREEN: Self = Self::Byte(49); + pub const CYAN2: Self = Self::Byte(50); + pub const CYAN1: Self = Self::Byte(51); + pub const DARKRED: Self = Self::Byte(52); + pub const DEEPPINK4: Self = Self::Byte(53); + pub const PURPLE4: Self = Self::Byte(54); + pub const PURPLE4_: Self = Self::Byte(55); + pub const PURPLE3: Self = Self::Byte(56); + pub const BLUEVIOLET: Self = Self::Byte(57); + pub const ORANGE4: Self = Self::Byte(58); + pub const GREY37: Self = Self::Byte(59); + pub const MEDIUMPURPLE4: Self = Self::Byte(60); + pub const SLATEBLUE3: Self = Self::Byte(61); + pub const SLATEBLUE3_: Self = Self::Byte(62); + pub const ROYALBLUE1: Self = Self::Byte(63); + pub const CHARTREUSE4: Self = Self::Byte(64); + pub const DARKSEAGREEN4: Self = Self::Byte(65); + pub const PALETURQUOISE4: Self = Self::Byte(66); + pub const STEELBLUE: Self = Self::Byte(67); + pub const STEELBLUE3: Self = Self::Byte(68); + pub const CORNFLOWERBLUE: Self = Self::Byte(69); + pub const CHARTREUSE3: Self = Self::Byte(70); + pub const DARKSEAGREEN4_: Self = Self::Byte(71); + pub const CADETBLUE: Self = Self::Byte(72); + pub const CADETBLUE_: Self = Self::Byte(73); + pub const SKYBLUE3: Self = Self::Byte(74); + pub const STEELBLUE1: Self = Self::Byte(75); + pub const CHARTREUSE3_: Self = Self::Byte(76); + pub const PALEGREEN3: Self = Self::Byte(77); + pub const SEAGREEN3: Self = Self::Byte(78); + pub const AQUAMARINE3: Self = Self::Byte(79); + pub const MEDIUMTURQUOISE: Self = Self::Byte(80); + pub const STEELBLUE1_: Self = Self::Byte(81); + pub const CHARTREUSE2: Self = Self::Byte(82); + pub const SEAGREEN2: Self = Self::Byte(83); + pub const SEAGREEN1: Self = Self::Byte(84); + pub const SEAGREEN1_: Self = Self::Byte(85); + pub const AQUAMARINE1: Self = Self::Byte(86); + pub const DARKSLATEGRAY2: Self = Self::Byte(87); + pub const DARKRED_: Self = Self::Byte(88); + pub const DEEPPINK4_: Self = Self::Byte(89); + pub const DARKMAGENTA: Self = Self::Byte(90); + pub const DARKMAGENTA_: Self = Self::Byte(91); + pub const DARKVIOLET: Self = Self::Byte(92); + pub const PURPLE_: Self = Self::Byte(93); + pub const ORANGE4_: Self = Self::Byte(94); + pub const LIGHTPINK4: Self = Self::Byte(95); + pub const PLUM4: Self = Self::Byte(96); + pub const MEDIUMPURPLE3: Self = Self::Byte(97); + pub const MEDIUMPURPLE3_: Self = Self::Byte(98); + pub const SLATEBLUE1: Self = Self::Byte(99); + pub const YELLOW4: Self = Self::Byte(100); + pub const WHEAT4: Self = Self::Byte(101); + pub const GREY53: Self = Self::Byte(102); + pub const LIGHTSLATEGREY: Self = Self::Byte(103); + pub const MEDIUMPURPLE: Self = Self::Byte(104); + pub const LIGHTSLATEBLUE: Self = Self::Byte(105); + pub const YELLOW4_: Self = Self::Byte(106); + pub const DARKOLIVEGREEN3: Self = Self::Byte(107); + pub const DARKSEAGREEN: Self = Self::Byte(108); + pub const LIGHTSKYBLUE3: Self = Self::Byte(109); + pub const LIGHTSKYBLUE3_: Self = Self::Byte(110); + pub const SKYBLUE2: Self = Self::Byte(111); + pub const CHARTREUSE2_: Self = Self::Byte(112); + pub const DARKOLIVEGREEN3_: Self = Self::Byte(113); + pub const PALEGREEN3_: Self = Self::Byte(114); + pub const DARKSEAGREEN3: Self = Self::Byte(115); + pub const DARKSLATEGRAY3: Self = Self::Byte(116); + pub const SKYBLUE1: Self = Self::Byte(117); + pub const CHARTREUSE1: Self = Self::Byte(118); + pub const LIGHTGREEN: Self = Self::Byte(119); + pub const LIGHTGREEN_: Self = Self::Byte(120); + pub const PALEGREEN1: Self = Self::Byte(121); + pub const AQUAMARINE1_: Self = Self::Byte(122); + pub const DARKSLATEGRAY1: Self = Self::Byte(123); + pub const RED3: Self = Self::Byte(124); + pub const DEEPPINK4__: Self = Self::Byte(125); + pub const MEDIUMVIOLETRED: Self = Self::Byte(126); + pub const MAGENTA3: Self = Self::Byte(127); + pub const DARKVIOLET_: Self = Self::Byte(128); + pub const PURPLE__: Self = Self::Byte(129); + pub const DARKORANGE3: Self = Self::Byte(130); + pub const INDIANRED: Self = Self::Byte(131); + pub const HOTPINK3: Self = Self::Byte(132); + pub const MEDIUMORCHID3: Self = Self::Byte(133); + pub const MEDIUMORCHID: Self = Self::Byte(134); + pub const MEDIUMPURPLE2: Self = Self::Byte(135); + pub const DARKGOLDENROD: Self = Self::Byte(136); + pub const LIGHTSALMON3: Self = Self::Byte(137); + pub const ROSYBROWN: Self = Self::Byte(138); + pub const GREY63: Self = Self::Byte(139); + pub const MEDIUMPURPLE2_: Self = Self::Byte(140); + pub const MEDIUMPURPLE1: Self = Self::Byte(141); + pub const GOLD3: Self = Self::Byte(142); + pub const DARKKHAKI: Self = Self::Byte(143); + pub const NAVAJOWHITE3: Self = Self::Byte(144); + pub const GREY69: Self = Self::Byte(145); + pub const LIGHTSTEELBLUE3: Self = Self::Byte(146); + pub const LIGHTSTEELBLUE: Self = Self::Byte(147); + pub const YELLOW3: Self = Self::Byte(148); + pub const DARKOLIVEGREEN3__: Self = Self::Byte(149); + pub const DARKSEAGREEN3_: Self = Self::Byte(150); + pub const DARKSEAGREEN2: Self = Self::Byte(151); + pub const LIGHTCYAN3: Self = Self::Byte(152); + pub const LIGHTSKYBLUE1: Self = Self::Byte(153); + pub const GREENYELLOW: Self = Self::Byte(154); + pub const DARKOLIVEGREEN2: Self = Self::Byte(155); + pub const PALEGREEN1_: Self = Self::Byte(156); + pub const DARKSEAGREEN2_: Self = Self::Byte(157); + pub const DARKSEAGREEN1: Self = Self::Byte(158); + pub const PALETURQUOISE1: Self = Self::Byte(159); + pub const RED3_: Self = Self::Byte(160); + pub const DEEPPINK3: Self = Self::Byte(161); + pub const DEEPPINK3_: Self = Self::Byte(162); + pub const MAGENTA3_: Self = Self::Byte(163); + pub const MAGENTA3__: Self = Self::Byte(164); + pub const MAGENTA2: Self = Self::Byte(165); + pub const DARKORANGE3_: Self = Self::Byte(166); + pub const INDIANRED_: Self = Self::Byte(167); + pub const HOTPINK3_: Self = Self::Byte(168); + pub const HOTPINK2: Self = Self::Byte(169); + pub const ORCHID: Self = Self::Byte(170); + pub const MEDIUMORCHID1: Self = Self::Byte(171); + pub const ORANGE3: Self = Self::Byte(172); + pub const LIGHTSALMON3_: Self = Self::Byte(173); + pub const LIGHTPINK3: Self = Self::Byte(174); + pub const PINK3: Self = Self::Byte(175); + pub const PLUM3: Self = Self::Byte(176); + pub const VIOLET: Self = Self::Byte(177); + pub const GOLD3_: Self = Self::Byte(178); + pub const LIGHTGOLDENROD3: Self = Self::Byte(179); + pub const TAN: Self = Self::Byte(180); + pub const MISTYROSE3: Self = Self::Byte(181); + pub const THISTLE3: Self = Self::Byte(182); + pub const PLUM2: Self = Self::Byte(183); + pub const YELLOW3_: Self = Self::Byte(184); + pub const KHAKI3: Self = Self::Byte(185); + pub const LIGHTGOLDENROD2: Self = Self::Byte(186); + pub const LIGHTYELLOW3: Self = Self::Byte(187); + pub const GREY84: Self = Self::Byte(188); + pub const LIGHTSTEELBLUE1: Self = Self::Byte(189); + pub const YELLOW2: Self = Self::Byte(190); + pub const DARKOLIVEGREEN1: Self = Self::Byte(191); + pub const DARKOLIVEGREEN1_: Self = Self::Byte(192); + pub const DARKSEAGREEN1_: Self = Self::Byte(193); + pub const HONEYDEW2: Self = Self::Byte(194); + pub const LIGHTCYAN1: Self = Self::Byte(195); + pub const RED1: Self = Self::Byte(196); + pub const DEEPPINK2: Self = Self::Byte(197); + pub const DEEPPINK1: Self = Self::Byte(198); + pub const DEEPPINK1_: Self = Self::Byte(199); + pub const MAGENTA2_: Self = Self::Byte(200); + pub const MAGENTA1: Self = Self::Byte(201); + pub const ORANGERED1: Self = Self::Byte(202); + pub const INDIANRED1: Self = Self::Byte(203); + pub const INDIANRED1_: Self = Self::Byte(204); + pub const HOTPINK: Self = Self::Byte(205); + pub const HOTPINK_: Self = Self::Byte(206); + pub const MEDIUMORCHID1_: Self = Self::Byte(207); + pub const DARKORANGE: Self = Self::Byte(208); + pub const SALMON1: Self = Self::Byte(209); + pub const LIGHTCORAL: Self = Self::Byte(210); + pub const PALEVIOLETRED1: Self = Self::Byte(211); + pub const ORCHID2: Self = Self::Byte(212); + pub const ORCHID1: Self = Self::Byte(213); + pub const ORANGE1: Self = Self::Byte(214); + pub const SANDYBROWN: Self = Self::Byte(215); + pub const LIGHTSALMON1: Self = Self::Byte(216); + pub const LIGHTPINK1: Self = Self::Byte(217); + pub const PINK1: Self = Self::Byte(218); + pub const PLUM1: Self = Self::Byte(219); + pub const GOLD1: Self = Self::Byte(220); + pub const LIGHTGOLDENROD2_: Self = Self::Byte(221); + pub const LIGHTGOLDENROD2__: Self = Self::Byte(222); + pub const NAVAJOWHITE1: Self = Self::Byte(223); + pub const MISTYROSE1: Self = Self::Byte(224); + pub const THISTLE1: Self = Self::Byte(225); + pub const YELLOW1: Self = Self::Byte(226); + pub const LIGHTGOLDENROD1: Self = Self::Byte(227); + pub const KHAKI1: Self = Self::Byte(228); + pub const WHEAT1: Self = Self::Byte(229); + pub const CORNSILK1: Self = Self::Byte(230); + pub const GREY100: Self = Self::Byte(231); + pub const GREY3: Self = Self::Byte(232); + pub const GREY7: Self = Self::Byte(233); + pub const GREY11: Self = Self::Byte(234); + pub const GREY15: Self = Self::Byte(235); + pub const GREY19: Self = Self::Byte(236); + pub const GREY23: Self = Self::Byte(237); + pub const GREY27: Self = Self::Byte(238); + pub const GREY30: Self = Self::Byte(239); + pub const GREY35: Self = Self::Byte(240); + pub const GREY39: Self = Self::Byte(241); + pub const GREY42: Self = Self::Byte(242); + pub const GREY46: Self = Self::Byte(243); + pub const GREY50: Self = Self::Byte(244); + pub const GREY54: Self = Self::Byte(245); + pub const GREY58: Self = Self::Byte(246); + pub const GREY62: Self = Self::Byte(247); + pub const GREY66: Self = Self::Byte(248); + pub const GREY70: Self = Self::Byte(249); + pub const GREY74: Self = Self::Byte(250); + pub const GREY78: Self = Self::Byte(251); + pub const GREY82: Self = Self::Byte(252); + pub const GREY85: Self = Self::Byte(253); + pub const GREY89: Self = Self::Byte(254); + pub const GREY93: Self = Self::Byte(255); } } diff --git a/meli/src/terminal/embedded/terminal.rs b/meli/src/terminal/embedded/terminal.rs index 84cc93eb..2d167141 100644 --- a/meli/src/terminal/embedded/terminal.rs +++ b/meli/src/terminal/embedded/terminal.rs @@ -314,7 +314,7 @@ impl EmbeddedGrid { pub fn process_byte(&mut self, stdin: &mut std::fs::File, byte: u8) { let area = self.area(); - let EmbeddedGrid { + let Self { ref mut cursor, ref mut scroll_region, ref mut terminal_size, diff --git a/meli/src/terminal/keys.rs b/meli/src/terminal/keys.rs index aeea0920..9dba778a 100644 --- a/meli/src/terminal/keys.rs +++ b/meli/src/terminal/keys.rs @@ -173,31 +173,31 @@ impl std::fmt::Display for Key { impl<'a> From<&'a String> for Key { fn from(v: &'a String) -> Self { - Key::Paste(v.to_string()) + Self::Paste(v.to_string()) } } impl From for Key { fn from(k: TermionKey) -> Self { match k { - TermionKey::Backspace => Key::Backspace, - TermionKey::Left => Key::Left, - TermionKey::Right => Key::Right, - TermionKey::Up => Key::Up, - TermionKey::Down => Key::Down, - TermionKey::Home => Key::Home, - TermionKey::End => Key::End, - TermionKey::PageUp => Key::PageUp, - TermionKey::PageDown => Key::PageDown, - TermionKey::Delete => Key::Delete, - TermionKey::Insert => Key::Insert, - TermionKey::F(u) => Key::F(u), - TermionKey::Char(c) => Key::Char(c), - TermionKey::Alt(c) => Key::Alt(c), - TermionKey::Ctrl(c) => Key::Ctrl(c), - TermionKey::Null => Key::Null, - TermionKey::Esc => Key::Esc, - _ => Key::Char(' '), + TermionKey::Backspace => Self::Backspace, + TermionKey::Left => Self::Left, + TermionKey::Right => Self::Right, + TermionKey::Up => Self::Up, + TermionKey::Down => Self::Down, + TermionKey::Home => Self::Home, + TermionKey::End => Self::End, + TermionKey::PageUp => Self::PageUp, + TermionKey::PageDown => Self::PageDown, + TermionKey::Delete => Self::Delete, + TermionKey::Insert => Self::Insert, + TermionKey::F(u) => Self::F(u), + TermionKey::Char(c) => Self::Char(c), + TermionKey::Alt(c) => Self::Alt(c), + TermionKey::Ctrl(c) => Self::Ctrl(c), + TermionKey::Null => Self::Null, + TermionKey::Esc => Self::Esc, + _ => Self::Char(' '), } } } @@ -399,27 +399,27 @@ impl Serialize for Key { S: Serializer, { match self { - Key::Backspace => serializer.serialize_str("Backspace"), - Key::Left => serializer.serialize_str("Left"), - Key::Right => serializer.serialize_str("Right"), - Key::Up => serializer.serialize_str("Up"), - Key::Down => serializer.serialize_str("Down"), - Key::Home => serializer.serialize_str("Home"), - Key::End => serializer.serialize_str("End"), - Key::PageUp => serializer.serialize_str("PageUp"), - Key::PageDown => serializer.serialize_str("PageDown"), - Key::Delete => serializer.serialize_str("Delete"), - Key::Insert => serializer.serialize_str("Insert"), - Key::Esc => serializer.serialize_str("Esc"), - Key::Char('\n') => serializer.serialize_str("Enter"), - Key::Char('\t') => serializer.serialize_str("Tab"), - Key::Char(c) => serializer.serialize_char(*c), - Key::F(n) => serializer.serialize_str(&format!("F{}", n)), - Key::Alt(c) => serializer.serialize_str(&format!("M-{}", c)), - Key::Ctrl(c) => serializer.serialize_str(&format!("C-{}", c)), - Key::Null => serializer.serialize_str("Null"), - Key::Mouse(mev) => mev.serialize(serializer), - Key::Paste(s) => serializer.serialize_str(s), + Self::Backspace => serializer.serialize_str("Backspace"), + Self::Left => serializer.serialize_str("Left"), + Self::Right => serializer.serialize_str("Right"), + Self::Up => serializer.serialize_str("Up"), + Self::Down => serializer.serialize_str("Down"), + Self::Home => serializer.serialize_str("Home"), + Self::End => serializer.serialize_str("End"), + Self::PageUp => serializer.serialize_str("PageUp"), + Self::PageDown => serializer.serialize_str("PageDown"), + Self::Delete => serializer.serialize_str("Delete"), + Self::Insert => serializer.serialize_str("Insert"), + Self::Esc => serializer.serialize_str("Esc"), + Self::Char('\n') => serializer.serialize_str("Enter"), + Self::Char('\t') => serializer.serialize_str("Tab"), + Self::Char(c) => serializer.serialize_char(*c), + Self::F(n) => serializer.serialize_str(&format!("F{}", n)), + Self::Alt(c) => serializer.serialize_str(&format!("M-{}", c)), + Self::Ctrl(c) => serializer.serialize_str(&format!("C-{}", c)), + Self::Null => serializer.serialize_str("Null"), + Self::Mouse(mev) => mev.serialize(serializer), + Self::Paste(s) => serializer.serialize_str(s), } } } diff --git a/meli/src/terminal/screen.rs b/meli/src/terminal/screen.rs index 6b635c0b..15f434f2 100644 --- a/meli/src/terminal/screen.rs +++ b/meli/src/terminal/screen.rs @@ -45,7 +45,7 @@ type DrawHorizontalSegmentFn = fn(&mut CellBuffer, &mut StateStdout, usize, usiz pub struct ScreenGeneration((u64, u64)); impl ScreenGeneration { - pub const NIL: ScreenGeneration = Self((0, 0)); + pub const NIL: Self = Self((0, 0)); #[inline] pub fn next(self) -> Self { @@ -234,7 +234,7 @@ impl Screen { Self::init(Tty { stdout: None, mouse: false, - draw_horizontal_segment_fn: Screen::draw_horizontal_segment, + draw_horizontal_segment_fn: Self::draw_horizontal_segment, }) } @@ -328,7 +328,10 @@ impl Screen { } pub fn switch_to_alternate_screen(&mut self, context: &crate::Context) { - let mut stdout = BufWriter::with_capacity(240 * 80, Box::new(std::io::stdout()) as _); + let mut stdout = BufWriter::with_capacity( + 240 * 80, + Box::new(std::io::stdout()) as Box, + ); write!( &mut stdout, diff --git a/meli/src/terminal/text_editing.rs b/meli/src/terminal/text_editing.rs index 7c5de38c..c9555ae9 100644 --- a/meli/src/terminal/text_editing.rs +++ b/meli/src/terminal/text_editing.rs @@ -30,7 +30,7 @@ pub struct UText { impl UText { pub fn new(content: String) -> Self { - UText { + Self { cursor_pos: content.len(), grapheme_cursor_pos: content.split_graphemes().len(), content, diff --git a/meli/src/types.rs b/meli/src/types.rs index 78719ac9..07a6754a 100644 --- a/meli/src/types.rs +++ b/meli/src/types.rs @@ -117,12 +117,12 @@ pub enum NotificationType { impl std::fmt::Display for NotificationType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match *self { - NotificationType::Info => write!(f, "info"), - NotificationType::Error(melib::error::ErrorKind::None) => write!(f, "error"), - NotificationType::Error(kind) => write!(f, "error: {}", kind), - NotificationType::NewMail => write!(f, "new mail"), - NotificationType::SentMail => write!(f, "sent mail"), - NotificationType::Saved => write!(f, "saved"), + Self::Info => write!(f, "info"), + Self::Error(melib::error::ErrorKind::None) => write!(f, "error"), + Self::Error(kind) => write!(f, "error: {}", kind), + Self::NewMail => write!(f, "new mail"), + Self::SentMail => write!(f, "sent mail"), + Self::Saved => write!(f, "saved"), } } } @@ -187,7 +187,7 @@ impl std::fmt::Debug for CallbackFn { impl From for UIEvent { fn from(event: RefreshEvent) -> Self { - UIEvent::RefreshEvent(Box::new(event)) + Self::RefreshEvent(Box::new(event)) } } @@ -207,11 +207,11 @@ impl std::fmt::Display for UIMode { f, "{}", match *self { - UIMode::Normal => "NORMAL", - UIMode::Insert => "INSERT", - UIMode::Command => "COMMAND", - UIMode::Fork => "FORK", - UIMode::Embedded => "EMBEDDED", + Self::Normal => "NORMAL", + Self::Insert => "INSERT", + Self::Command => "COMMAND", + Self::Fork => "FORK", + Self::Embedded => "EMBEDDED", } ) } @@ -233,15 +233,15 @@ pub mod segment_tree { } impl From> for SegmentTree { - fn from(val: SmallVec<[u8; 1024]>) -> SegmentTree { - SegmentTree::new(val) + fn from(val: SmallVec<[u8; 1024]>) -> Self { + Self::new(val) } } impl SegmentTree { - pub fn new(val: SmallVec<[u8; 1024]>) -> SegmentTree { + pub fn new(val: SmallVec<[u8; 1024]>) -> Self { if val.is_empty() { - return SegmentTree { + return Self { array: val.clone(), tree: val, }; @@ -262,7 +262,7 @@ pub mod segment_tree { segment_tree[i] = std::cmp::max(segment_tree[2 * i], segment_tree[2 * i + 1]); } - SegmentTree { + Self { array: val, tree: segment_tree, } @@ -348,7 +348,7 @@ pub struct RateLimit { impl RateLimit { pub fn new(reqs: u64, millis: u64, job_executor: Arc) -> Self { - RateLimit { + Self { last_tick: std::time::Instant::now(), timer: job_executor.create_timer( std::time::Duration::from_secs(0), diff --git a/meli/src/utilities.rs b/meli/src/utilities.rs index ed9fda86..c53190dc 100644 --- a/meli/src/utilities.rs +++ b/meli/src/utilities.rs @@ -114,7 +114,7 @@ impl StatusBar { None => {} } - StatusBar { + Self { container, status: String::with_capacity(256), status_message: String::with_capacity(256), @@ -812,9 +812,12 @@ impl Component for StatusBar { fn children(&self) -> IndexMap { let mut ret = IndexMap::default(); - ret.insert(self.container.id(), &self.container as _); - ret.insert(self.ex_buffer.id(), &self.ex_buffer as _); - ret.insert(self.progress_spinner.id(), &self.progress_spinner as _); + ret.insert(self.container.id(), &self.container as &dyn Component); + ret.insert(self.ex_buffer.id(), &self.ex_buffer as &dyn Component); + ret.insert( + self.progress_spinner.id(), + &self.progress_spinner as &dyn Component, + ); ret } @@ -862,7 +865,7 @@ pub struct Tabbed { impl Tabbed { pub fn new(children: Vec>, context: &Context) -> Self { let pinned = children.len(); - let mut ret = Tabbed { + let mut ret = Self { help_view: HelpView { content: Screen::::new(), curr_views: children @@ -1565,7 +1568,7 @@ impl Component for Tabbed { fn children(&self) -> IndexMap { let mut ret = IndexMap::default(); for c in &self.children { - ret.insert(c.id(), c as _); + ret.insert(c.id(), c as &dyn Component); } ret } diff --git a/meli/src/utilities/dialogs.rs b/meli/src/utilities/dialogs.rs index 9528bd1c..83d0be0f 100644 --- a/meli/src/utilities/dialogs.rs +++ b/meli/src/utilities/dialogs.rs @@ -94,7 +94,7 @@ impl PartialEq for Selector { - fn eq(&self, other: &Selector) -> bool { + fn eq(&self, other: &Self) -> bool { self.entries == other.entries } } diff --git a/meli/src/utilities/tables.rs b/meli/src/utilities/tables.rs index e2fbcaa6..d5a0c10b 100644 --- a/meli/src/utilities/tables.rs +++ b/meli/src/utilities/tables.rs @@ -144,7 +144,7 @@ impl Default for DataColumns { for elem in &mut data[..] { elem.write(cl()); } - let ptr = &data as *const [MaybeUninit; N]; + let ptr = std::ptr::addr_of!(data); unsafe { (ptr as *const [T; N]).read() } } diff --git a/meli/src/utilities/text.rs b/meli/src/utilities/text.rs index e3ab77b3..234cd29f 100644 --- a/meli/src/utilities/text.rs +++ b/meli/src/utilities/text.rs @@ -39,7 +39,7 @@ impl std::fmt::Debug for TextField { } impl Default for TextField { - fn default() -> TextField { + fn default() -> Self { Self { inner: UText::new(String::with_capacity(256)), autocomplete: None, diff --git a/meli/src/utilities/widgets.rs b/meli/src/utilities/widgets.rs index 8d20fc62..78246be0 100644 --- a/meli/src/utilities/widgets.rs +++ b/meli/src/utilities/widgets.rs @@ -49,8 +49,8 @@ impl std::fmt::Debug for Field { } impl Default for Field { - fn default() -> Field { - Field::Text(TextField::default()) + fn default() -> Self { + Self::Text(TextField::default()) } } @@ -253,8 +253,8 @@ impl FormWidget action: (Cow<'static, str>, T), cursor_up_shortcut: Key, cursor_down_shortcut: Key, - ) -> FormWidget { - FormWidget { + ) -> Self { + Self { buttons: ButtonWidget::new(action), focus: FormFocus::Fields, hide_buttons: false, @@ -556,8 +556,8 @@ impl ButtonWidget where T: 'static + std::fmt::Debug + Copy + Default + Send + Sync, { - pub fn new(init_val: (Cow<'static, str>, T)) -> ButtonWidget { - ButtonWidget { + pub fn new(init_val: (Cow<'static, str>, T)) -> Self { + Self { layout: vec![init_val.0.clone()], buttons: vec![init_val].into_iter().collect(), result: None, @@ -676,7 +676,7 @@ impl AutoCompleteEntry { impl From for AutoCompleteEntry { fn from(val: String) -> Self { - AutoCompleteEntry { + Self { entry: val, description: String::new(), } @@ -686,7 +686,7 @@ impl From for AutoCompleteEntry { impl From<&(&str, &str, TokenStream)> for AutoCompleteEntry { fn from(val: &(&str, &str, TokenStream)) -> Self { let (a, b, _) = val; - AutoCompleteEntry { + Self { entry: a.to_string(), description: b.to_string(), } @@ -696,7 +696,7 @@ impl From<&(&str, &str, TokenStream)> for AutoCompleteEntry { impl From<(String, String)> for AutoCompleteEntry { fn from(val: (String, String)) -> Self { let (a, b) = val; - AutoCompleteEntry { + Self { entry: a, description: b, } @@ -731,7 +731,7 @@ impl Component for AutoComplete { } let page_no = (self.cursor.saturating_sub(1)).wrapping_div(rows); let top_idx = page_no * rows; - let x_offset = if rows < self.entries.len() { 1 } else { 0 }; + let x_offset = usize::from(rows < self.entries.len()); grid.clear_area(area, crate::conf::value(context, "theme_default")); let width = self @@ -817,7 +817,7 @@ impl Component for AutoComplete { impl AutoComplete { pub fn new(entries: Vec) -> Box { - let mut ret = AutoComplete { + let mut ret = Self { entries: Vec::new(), cursor: 0, dirty: true, @@ -1102,7 +1102,7 @@ impl ProgressSpinner { theme_attr.attrs |= Attr::REVERSE; } theme_attr.attrs |= Attr::BOLD; - ProgressSpinner { + Self { timer, stage: 0, kind: Ok(kind),