From 9331b2001d0a855bed38f5397efa39765891288b Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 2 Nov 2023 22:19:13 +0100 Subject: [PATCH] improve code with clippy --- src/model/logbook.rs | 6 +++--- src/tera/log.rs | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/model/logbook.rs b/src/model/logbook.rs index f03f209..b856afa 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -124,7 +124,7 @@ pub enum LogbookCreateError { impl From for LogbookCreateError { fn from(value: LogbookUpdateError) -> Self { - return match value { + match value { LogbookUpdateError::NotYourEntry => LogbookCreateError::NotYourEntry, LogbookUpdateError::TooManyRowers(a, b) => LogbookCreateError::TooManyRowers(a, b), LogbookUpdateError::RowerCreateError(a, b) => { @@ -140,7 +140,7 @@ impl From for LogbookCreateError { LogbookUpdateError::UserNotAllowedToUseBoat => { LogbookCreateError::UserNotAllowedToUseBoat } - }; + } } } @@ -429,7 +429,7 @@ ORDER BY departure DESC return Err(LogbookUpdateError::SteeringPersonNotInRowers); } - if !boat.shipmaster_allowed(&user).await && self.shipmaster != user.id { + if !boat.shipmaster_allowed(user).await && self.shipmaster != user.id { //second part: //shipmaster has //entered a diff --git a/src/tera/log.rs b/src/tera/log.rs index 013b67f..f9ee2fb 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -217,12 +217,10 @@ async fn create_kiosk( User::find_by_id(db, boat.owner.unwrap() as i32) .await .unwrap() + } else if let Some(shipmaster) = data.shipmaster { + User::find_by_id(db, shipmaster as i32).await.unwrap() } else { - if let Some(shipmaster) = data.shipmaster { - User::find_by_id(db, shipmaster as i32).await.unwrap() - } else { - User::find_by_id(db, data.rowers[0] as i32).await.unwrap() - } + User::find_by_id(db, data.rowers[0] as i32).await.unwrap() }; Log::create( db,