aboutsummaryrefslogtreecommitdiff
path: root/src/controller
diff options
context:
space:
mode:
authorJoris2023-04-17 21:10:48 +0200
committerJoris2023-04-17 21:10:48 +0200
commit459016e70dd4933a8082d27748097de81a3e53ff (patch)
tree0ed14ecc8762d62a55bf8c05356bcc984b1a0cea /src/controller
parent3932daa26360d6e03807381d0b8ffa2d0e704847 (diff)
Follow clippy indications
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/balance.rs11
-rw-r--r--src/controller/login.rs2
-rw-r--r--src/controller/utils.rs2
3 files changed, 7 insertions, 8 deletions
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<Body> {
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<Body> {
}
fn get_template_user_payments(
- users: &Vec<User>,
+ users: &[User],
user_payments: &HashMap<i64, i64>,
) -> 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<User>,
+ users: &[User],
user_incomes: &HashMap<i64, i64>,
) -> 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<Body> {
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<Body> {
- let mut context = context.clone();
+ let mut context = context;
context.insert("assets", assets);
let response = match templates.render(path, &context) {