diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-12-27 18:40:26 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2022-12-27 18:40:26 +0200 |
commit | de2f46fe611726a445c1e06cbc35343e716aa335 (patch) | |
tree | f6bf5e697cfb1c5f329845390257a597f9a77af3 | |
parent | 5443b7e8f300a0084abde7354360ecbe909178bb (diff) | |
download | meli-de2f46fe611726a445c1e06cbc35343e716aa335.zip |
rustfmt changes
-rw-r--r-- | melib/src/backends.rs | 2 | ||||
-rw-r--r-- | melib/src/backends/imap.rs | 4 | ||||
-rw-r--r-- | melib/src/backends/imap/connection.rs | 5 | ||||
-rw-r--r-- | melib/src/backends/imap/operations.rs | 18 | ||||
-rw-r--r-- | melib/src/backends/maildir/backend.rs | 2 | ||||
-rw-r--r-- | melib/src/backends/mbox.rs | 8 | ||||
-rw-r--r-- | melib/src/connections.rs | 13 | ||||
-rw-r--r-- | melib/src/gpgme/mod.rs | 22 | ||||
-rw-r--r-- | src/components/mail/compose/gpg.rs | 5 | ||||
-rw-r--r-- | src/conf.rs | 6 | ||||
-rw-r--r-- | src/conf/accounts.rs | 6 | ||||
-rw-r--r-- | src/conf/themes.rs | 15 | ||||
-rw-r--r-- | src/main.rs | 10 |
13 files changed, 40 insertions, 76 deletions
diff --git a/melib/src/backends.rs b/melib/src/backends.rs index 588291a5..1952123b 100644 --- a/melib/src/backends.rs +++ b/melib/src/backends.rs @@ -40,7 +40,7 @@ pub use self::imap::ImapType; #[cfg(feature = "imap_backend")] pub use self::nntp::NntpType; use crate::conf::AccountSettings; -use crate::error::{ErrorKind, Error, Result}; +use crate::error::{Error, ErrorKind, Result}; #[cfg(feature = "maildir_backend")] use self::maildir::MaildirType; diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs index 55d68111..9e6e672d 100644 --- a/melib/src/backends/imap.rs +++ b/melib/src/backends/imap.rs @@ -1245,9 +1245,7 @@ impl MailBackend for ImapType { )); } } - Err(Error::new( - String::from_utf8_lossy(&response).to_string(), - )) + Err(Error::new(String::from_utf8_lossy(&response).to_string())) })) } } diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index 7b697b76..8918117c 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -240,10 +240,7 @@ impl ImapStream { let addr = if let Ok(a) = lookup_ipv4(path, server_conf.server_port) { a } else { - return Err(Error::new(format!( - "Could not lookup address {}", - &path - ))); + return Err(Error::new(format!("Could not lookup address {}", &path))); }; AsyncWrapper::new(Connection::Tcp( if let Some(timeout) = server_conf.timeout { diff --git a/melib/src/backends/imap/operations.rs b/melib/src/backends/imap/operations.rs index ccb79ae4..f7b48e33 100644 --- a/melib/src/backends/imap/operations.rs +++ b/melib/src/backends/imap/operations.rs @@ -82,11 +82,10 @@ impl BackendOp for ImapOp { ); let mut results = protocol_parser::fetch_responses(&response)?.1; if results.len() != 1 { - return Err(Error::new(format!( - "Invalid/unexpected response: {:?}", - response - )) - .set_summary(format!("message with UID {} was not found?", uid))); + return Err( + Error::new(format!("Invalid/unexpected response: {:?}", response)) + .set_summary(format!("message with UID {} was not found?", uid)), + ); } let FetchResponse { uid: _uid, @@ -147,11 +146,10 @@ impl BackendOp for ImapOp { debug!(String::from_utf8_lossy(&response)); /* TODO: Trigger cache invalidation here. */ debug!("message with UID {} was not found", uid); - return Err(Error::new(format!( - "Invalid/unexpected response: {:?}", - response - )) - .set_summary(format!("message with UID {} was not found?", uid))); + return Err( + Error::new(format!("Invalid/unexpected response: {:?}", response)) + .set_summary(format!("message with UID {} was not found?", uid)), + ); } let (_uid, (_flags, _)) = v[0]; assert_eq!(_uid, uid); diff --git a/melib/src/backends/maildir/backend.rs b/melib/src/backends/maildir/backend.rs index 26c71366..0ca01fc5 100644 --- a/melib/src/backends/maildir/backend.rs +++ b/melib/src/backends/maildir/backend.rs @@ -28,7 +28,7 @@ use super::{MaildirMailbox, MaildirOp, MaildirPathTrait}; use crate::backends::{RefreshEventKind::*, *}; use crate::conf::AccountSettings; use crate::email::{Envelope, EnvelopeHash, Flag}; -use crate::error::{ErrorKind, Error, Result}; +use crate::error::{Error, ErrorKind, Result}; use crate::shellexpand::ShellExpandTrait; use crate::Collection; use futures::prelude::Stream; diff --git a/melib/src/backends/mbox.rs b/melib/src/backends/mbox.rs index b10102d6..e95951f6 100644 --- a/melib/src/backends/mbox.rs +++ b/melib/src/backends/mbox.rs @@ -126,7 +126,7 @@ use crate::collection::Collection; use crate::conf::AccountSettings; use crate::email::parser::BytesExt; use crate::email::*; -use crate::error::{ErrorKind, Error, Result}; +use crate::error::{Error, ErrorKind, Result}; use crate::get_path_hash; use crate::shellexpand::ShellExpandTrait; use nom::bytes::complete::tag; @@ -1244,10 +1244,8 @@ impl MailBackend for MboxType { _query: crate::search::Query, _mailbox_hash: Option<MailboxHash>, ) -> ResultFuture<SmallVec<[EnvelopeHash; 512]>> { - Err( - Error::new("Search is unimplemented for the mbox backend.") - .set_kind(ErrorKind::NotImplemented), - ) + Err(Error::new("Search is unimplemented for the mbox backend.") + .set_kind(ErrorKind::NotImplemented)) } fn create_mailbox( diff --git a/melib/src/connections.rs b/melib/src/connections.rs index 105f4ea7..5db98c94 100644 --- a/melib/src/connections.rs +++ b/melib/src/connections.rs @@ -270,10 +270,9 @@ pub fn lookup_ipv4(host: &str, port: u16) -> crate::Result<std::net::SocketAddr> } Err( - crate::error::Error::new(format!("Could not lookup address {}:{}", host, port)) - .set_kind(crate::error::ErrorKind::Network( - crate::error::NetworkErrorKind::HostLookupFailed, - )), + crate::error::Error::new(format!("Could not lookup address {}:{}", host, port)).set_kind( + crate::error::ErrorKind::Network(crate::error::NetworkErrorKind::HostLookupFailed), + ), ) } @@ -284,8 +283,10 @@ pub async fn timeout<O>(dur: Option<Duration>, f: impl Future<Output = O>) -> cr if let Some(dur) = dur { match future::select(f, smol::Timer::after(dur)).await { Either::Left((out, _)) => Ok(out), - Either::Right(_) => Err(crate::error::Error::new("Timed out.") - .set_kind(crate::error::ErrorKind::Timeout)), + Either::Right(_) => { + Err(crate::error::Error::new("Timed out.") + .set_kind(crate::error::ErrorKind::Timeout)) + } } } else { Ok(f.await) diff --git a/melib/src/gpgme/mod.rs b/melib/src/gpgme/mod.rs index e7da22f8..511d4ccd 100644 --- a/melib/src/gpgme/mod.rs +++ b/melib/src/gpgme/mod.rs @@ -23,7 +23,7 @@ use crate::email::{ pgp::{DecryptionMetadata, Recipient}, Address, }; -use crate::error::{ErrorKind, IntoError, Error, Result, ResultIntoError}; +use crate::error::{Error, ErrorKind, IntoError, Result, ResultIntoError}; use futures::FutureExt; use serde::{ de::{self, Deserialize}, @@ -259,9 +259,8 @@ impl Context { } let ret = Context { inner: Arc::new(ContextInner { - inner: core::ptr::NonNull::new(ptr).ok_or_else(|| { - Error::new("Could not use libgpgme").set_kind(ErrorKind::Bug) - })?, + inner: core::ptr::NonNull::new(ptr) + .ok_or_else(|| Error::new("Could not use libgpgme").set_kind(ErrorKind::Bug))?, lib, }), io_state, @@ -714,9 +713,8 @@ impl Context { let mut sig = Data { lib: self.inner.lib.clone(), kind: DataKind::Memory, - inner: core::ptr::NonNull::new(sig).ok_or_else(|| { - Error::new("internal libgpgme error").set_kind(ErrorKind::Bug) - })?, + inner: core::ptr::NonNull::new(sig) + .ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?, }; let io_state = self.io_state.clone(); @@ -818,9 +816,8 @@ impl Context { let mut plain = Data { lib: self.inner.lib.clone(), kind: DataKind::Memory, - inner: core::ptr::NonNull::new(plain).ok_or_else(|| { - Error::new("internal libgpgme error").set_kind(ErrorKind::Bug) - })?, + inner: core::ptr::NonNull::new(plain) + .ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?, }; let ctx = self.inner.clone(); @@ -1030,9 +1027,8 @@ impl Context { let mut cipher = Data { lib: self.inner.lib.clone(), kind: DataKind::Memory, - inner: core::ptr::NonNull::new(cipher).ok_or_else(|| { - Error::new("internal libgpgme error").set_kind(ErrorKind::Bug) - })?, + inner: core::ptr::NonNull::new(cipher) + .ok_or_else(|| Error::new("internal libgpgme error").set_kind(ErrorKind::Bug))?, }; let ctx = self.inner.clone(); diff --git a/src/components/mail/compose/gpg.rs b/src/components/mail/compose/gpg.rs index f79b3a1a..141caf0f 100644 --- a/src/components/mail/compose/gpg.rs +++ b/src/components/mail/compose/gpg.rs @@ -148,10 +148,7 @@ impl Component for KeySelection { } } else { *self = KeySelection::Error { - err: Error::new(format!( - "No keys found for {}.", - pattern - )), + err: Error::new(format!("No keys found for {}.", pattern)), id, } } diff --git a/src/conf.rs b/src/conf.rs index 08d31085..2ece4864 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -401,11 +401,7 @@ This is required so that you don't accidentally start meli and find out later th let mut file = OpenOptions::new().append(true).open(&path)?; file.write_all("[composing]\nsend_mail = 'false'\n".as_bytes()) .map_err(|err| { - Error::new(format!( - "Could not append to {}: {}", - path.display(), - err - )) + Error::new(format!("Could not append to {}: {}", path.display(), err)) })?; return FileSettings::validate(path, interactive, clear_extras); } diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs index ba0640c9..5efa4231 100644 --- a/src/conf/accounts.rs +++ b/src/conf/accounts.rs @@ -28,7 +28,7 @@ use crate::jobs::{JobExecutor, JobId, JoinHandle}; use indexmap::IndexMap; use melib::backends::*; use melib::email::*; -use melib::error::{ErrorKind, Error, Result}; +use melib::error::{Error, ErrorKind, Result}; use melib::text_processing::GlobMatch; use melib::thread::{SortField, SortOrder, Threads}; use melib::AddressBook; @@ -1394,9 +1394,7 @@ impl Account { ) }; melib::log(&error_message, melib::LoggingLevel::ERROR); - return Err( - Error::new(error_message).set_summary("Message not sent.") - ); + return Err(Error::new(error_message).set_summary("Message not sent.")); } Ok(()) } diff --git a/src/conf/themes.rs b/src/conf/themes.rs index 905b2293..204e8597 100644 --- a/src/conf/themes.rs +++ b/src/conf/themes.rs @@ -1212,23 +1212,14 @@ impl Themes { Themes::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 - ))); + return Err(Error::new(format!("light theme contains a cycle: {}", err))); } if let Err(err) = is_cyclic(&self.dark) { - return Err(Error::new(format!( - "dark theme contains a cycle: {}", - err - ))); + return Err(Error::new(format!("dark theme contains a cycle: {}", err))); } for (k, t) in self.other_themes.iter() { if let Err(err) = is_cyclic(t) { - return Err(Error::new(format!( - "{} theme contains a cycle: {}", - k, err - ))); + return Err(Error::new(format!("{} theme contains a cycle: {}", k, err))); } } Ok(()) diff --git a/src/main.rs b/src/main.rs index 8fbceeb8..dc74d2a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,10 +78,7 @@ fn parse_manpage(src: &str) -> Result<ManPages> { "meli.7" | "guide" => Ok(ManPages::Guide), "meli.conf" | "meli.conf.5" | "conf" | "config" | "configuration" => Ok(ManPages::Conf), "meli-themes" | "meli-themes.5" | "themes" | "theming" | "theme" => Ok(ManPages::Themes), - _ => Err(Error::new(format!( - "Invalid documentation page: {}", - src - ))), + _ => Err(Error::new(format!("Invalid documentation page: {}", src))), } } @@ -284,10 +281,7 @@ fn run_app(opt: Opt) -> Result<()> { path.display() ))); } else if !path.is_file() { - return Err(Error::new(format!( - "`{}` is a directory", - path.display() - ))); + return Err(Error::new(format!("`{}` is a directory", path.display()))); } } None => {} |