From 459016e70dd4933a8082d27748097de81a3e53ff Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 17 Apr 2023 21:10:48 +0200 Subject: Follow clippy indications --- src/controller/balance.rs | 11 +++++------ src/controller/login.rs | 2 +- src/controller/utils.rs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/controller') diff --git a/src/controller/balance.rs b/src/controller/balance.rs index 228ff04..adde8a9 100644 --- a/src/controller/balance.rs +++ b/src/controller/balance.rs @@ -24,8 +24,7 @@ pub async fn get(wallet: &Wallet) -> Response { let user_payments = db::payments::repartition(&wallet.pool).await; let template_user_payments = get_template_user_payments(&users, &user_payments); - let total_payments: i64 = - user_payments.clone().into_iter().map(|p| p.1).sum(); + let total_payments: i64 = user_payments.iter().map(|p| p.1).sum(); let exceeding_payers = payer::exceeding(&users, &user_incomes, &user_payments); @@ -47,11 +46,11 @@ pub async fn get(wallet: &Wallet) -> Response { } fn get_template_user_payments( - users: &Vec, + users: &[User], user_payments: &HashMap, ) -> Vec<(String, i64)> { let mut user_payments: Vec<(String, i64)> = users - .into_iter() + .iter() .map(|u| (u.name.clone(), *user_payments.get(&u.id).unwrap_or(&0))) .collect(); user_payments.sort_by_key(|i| i.1); @@ -59,11 +58,11 @@ fn get_template_user_payments( } fn get_template_user_incomes( - users: &Vec, + users: &[User], user_incomes: &HashMap, ) -> Vec<(String, i64)> { let mut user_incomes: Vec<(String, i64)> = users - .into_iter() + .iter() .map(|u| (u.name.clone(), *user_incomes.get(&u.id).unwrap_or(&0))) .collect(); user_incomes.sort_by_key(|i| i.1); diff --git a/src/controller/login.rs b/src/controller/login.rs index ea9db57..09a2786 100644 --- a/src/controller/login.rs +++ b/src/controller/login.rs @@ -81,6 +81,6 @@ pub async fn logout(config: Config, wallet: &Wallet) -> Response { if db::users::remove_login_token(&wallet.pool, wallet.user.id).await { utils::with_logout_cookie(config, utils::redirect("/")) } else { - error::error(&wallet, "Erreur serveur", "Erreur serveur") + error::error(wallet, "Erreur serveur", "Erreur serveur") } } diff --git a/src/controller/utils.rs b/src/controller/utils.rs index bd3007e..26db765 100644 --- a/src/controller/utils.rs +++ b/src/controller/utils.rs @@ -71,7 +71,7 @@ pub fn template( path: &str, context: Context, ) -> Response { - let mut context = context.clone(); + let mut context = context; context.insert("assets", assets); let response = match templates.render(path, &context) { -- cgit v1.2.3