From 6e1bc101bf79e70064c8b9116ee967a4eb6011b4 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 6 Sep 2023 14:39:36 +0200 Subject: [PATCH] clean code with clippy --- Cargo.lock | 8 ++++---- src/model/boat.rs | 2 +- src/model/boatdamage.rs | 2 +- src/model/logbook.rs | 10 ++++------ src/model/rower.rs | 2 +- src/model/tripdetails.rs | 4 ++-- src/tera/cox.rs | 6 +++--- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bc3a5f..fd4dd09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,9 +278,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2702,9 +2702,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", diff --git a/src/model/boat.rs b/src/model/boat.rs index ef6755d..ddd02fb 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -109,7 +109,7 @@ impl Boat { damage, on_water: boat.on_water(db).await, boat, - }) + }); } res } diff --git a/src/model/boatdamage.rs b/src/model/boatdamage.rs index 3e60085..7dbabfb 100644 --- a/src/model/boatdamage.rs +++ b/src/model/boatdamage.rs @@ -101,7 +101,7 @@ ORDER BY created_at DESC user_fixed, user_verified, boat_damage, - }) + }); } res } diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 10b814c..e38e1b8 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -226,9 +226,7 @@ ORDER BY departure DESC for rower in &log.rower { Rower::create(&mut tx, inserted_row.id, *rower) .await - .map_err(|e| { - return LogbookCreateError::RowerCreateError(*rower, e.to_string()); - })?; + .map_err(|e| LogbookCreateError::RowerCreateError(*rower, e.to_string()))?; } tx.commit().await.unwrap(); @@ -300,9 +298,9 @@ ORDER BY departure DESC self.remove_rowers(&mut tx).await; for rower in &log.rower { - Rower::create(&mut tx, self.id, *rower).await.map_err(|e| { - return LogbookUpdateError::RowerCreateError(*rower, e.to_string()); - })?; + Rower::create(&mut tx, self.id, *rower) + .await + .map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?; } tx.commit().await.unwrap(); diff --git a/src/model/rower.rs b/src/model/rower.rs index 99065ef..f6a40a8 100644 --- a/src/model/rower.rs +++ b/src/model/rower.rs @@ -39,7 +39,7 @@ WHERE id in (SELECT rower_id FROM rower WHERE logbook_id=?) ) .execute(db) .await - .map_err(|e| return e.to_string())?; + .map_err(|e| e.to_string())?; Ok(()) } diff --git a/src/model/tripdetails.rs b/src/model/tripdetails.rs index b913810..71a427c 100644 --- a/src/model/tripdetails.rs +++ b/src/model/tripdetails.rs @@ -120,9 +120,9 @@ ORDER BY day;", pub(crate) async fn user_allowed_to_change(&self, db: &SqlitePool, user: &User) -> bool { if self.belongs_to_event(db).await { - return user.is_admin; + user.is_admin } else { - return self.user_is_cox(db, user).await != CoxAtTrip::No; + self.user_is_cox(db, user).await != CoxAtTrip::No } } diff --git a/src/tera/cox.rs b/src/tera/cox.rs index 79bc5aa..a62e2b7 100644 --- a/src/tera/cox.rs +++ b/src/tera/cox.rs @@ -145,13 +145,13 @@ async fn remove(db: &State, planned_event_id: i64, cox: CoxUser) -> ) .await; - return Flash::success(Redirect::to("/"), "Erfolgreich abgemeldet!"); + Flash::success(Redirect::to("/"), "Erfolgreich abgemeldet!") } Err(TripHelpDeleteError::DetailsLocked) => { - return Flash::error(Redirect::to("/"), "Boot bereits eingeteilt"); + Flash::error(Redirect::to("/"), "Boot bereits eingeteilt") } Err(TripHelpDeleteError::CoxNotHelping) => { - return Flash::error(Redirect::to("/"), "Steuermann hilft nicht aus...") + Flash::error(Redirect::to("/"), "Steuermann hilft nicht aus...") } } } else {