Fix clippy lints

newstuff
Manos Pitsidianakis 2022-10-26 15:32:44 +03:00
parent 5f4c71b7f6
commit ddb6d225aa
6 changed files with 23 additions and 31 deletions

View File

@ -54,14 +54,10 @@ impl<'a> Into<ListTemplate<'a>> for (&'a DbVal<MailingList>, &'a Database) {
let posts = db.list_posts(list.pk, None).unwrap();
ListTemplate {
title: &list.name,
list: &list,
list,
posts,
months,
body: &list
.description
.as_ref()
.map(|s| s.as_str())
.unwrap_or_default(),
body: list.description.as_deref().unwrap_or_default(),
}
}
}
@ -141,7 +137,7 @@ async fn main() {
title: "mailing list archive",
description: "",
lists_len: lists.len(),
lists: lists,
lists,
};
let res = template.render().unwrap();
Ok(warp::reply::html(res))

View File

@ -664,10 +664,8 @@ fn run_app(opt: Opt) -> Result<()> {
hasher.finish()
}
let mut buf = Vec::with_capacity(4096);
let files = melib::backends::maildir::MaildirType::list_mail_in_maildir_fs(
maildir_path.clone(),
true,
)?;
let files =
melib::backends::maildir::MaildirType::list_mail_in_maildir_fs(maildir_path, true)?;
let mut ctr = 0;
for file in files {
let hash = get_file_hash(&file);

View File

@ -92,8 +92,7 @@ impl Configuration {
}
if path.starts_with("~") {
path = Path::new(&std::env::var("HOME").context("No $HOME set.")?)
.join(path.strip_prefix("~").context("Internal error while getting default database path: path starts with ~ but rust couldn't strip_refix(\"~\"")?)
.into();
.join(path.strip_prefix("~").context("Internal error while getting default database path: path starts with ~ but rust couldn't strip_refix(\"~\"")?);
}
let config: Configuration = Self::from_file(&path)?;
config.init_with()
@ -110,8 +109,7 @@ impl Configuration {
xdg::BaseDirectories::with_prefix("mailpot")?.place_config_file("config.toml")?;
if result.starts_with("~") {
result = Path::new(&std::env::var("HOME").context("No $HOME set.")?)
.join(result.strip_prefix("~").context("Internal error while getting default database path: path starts with ~ but rust couldn't strip_refix(\"~\"")?)
.into();
.join(result.strip_prefix("~").context("Internal error while getting default database path: path starts with ~ but rust couldn't strip_refix(\"~\"")?);
}
Ok(result)
}

View File

@ -160,21 +160,20 @@ impl Database {
if !recipients.is_empty() {
trace!("recipients: {:?}", &recipients);
match &configuration.send_mail {
crate::config::SendMail::Smtp(ref smtp_conf) => {
let smtp_conf = smtp_conf.clone();
use melib::futures;
use melib::smol;
use melib::smtp::*;
let mut conn = smol::future::block_on(smol::spawn(
SmtpConnection::new_connection(smtp_conf.clone()),
))?;
futures::executor::block_on(conn.mail_transaction(
&String::from_utf8_lossy(&bytes),
Some(recipients),
))?;
}
_ => {}
if let crate::config::SendMail::Smtp(ref smtp_conf) =
&configuration.send_mail
{
let smtp_conf = smtp_conf.clone();
use melib::futures;
use melib::smol;
use melib::smtp::*;
let mut conn = smol::future::block_on(smol::spawn(
SmtpConnection::new_connection(smtp_conf.clone()),
))?;
futures::executor::block_on(conn.mail_transaction(
&String::from_utf8_lossy(&bytes),
Some(recipients),
))?;
}
} else {
trace!("list has no recipients");

View File

@ -16,6 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#![allow(clippy::result_unit_err)]
use super::*;

View File

@ -77,7 +77,7 @@ where
}
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
pub struct MailingList {
pub pk: i64,
pub name: String,