clean code with clippy
This commit is contained in:
@ -73,10 +73,8 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
|
||||
#[get("/join/<trip_details_id>")]
|
||||
async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
||||
let trip_details = match TripDetails::find_by_id(db, trip_details_id).await {
|
||||
Some(trip_details) => trip_details,
|
||||
None => return Flash::error(Redirect::to("/"), "Trip_details do not exist."),
|
||||
};
|
||||
let Some(trip_details) = TripDetails::find_by_id(db, trip_details_id).await else { return Flash::error(Redirect::to("/"), "Trip_details do not exist.") };
|
||||
|
||||
match UserTrip::create(db, &user, &trip_details).await {
|
||||
Ok(_) => {
|
||||
Log::create(
|
||||
@ -111,12 +109,9 @@ async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash
|
||||
|
||||
#[get("/remove/<trip_details_id>")]
|
||||
async fn remove(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
||||
let trip_details = match TripDetails::find_by_id(db, trip_details_id).await {
|
||||
Some(trip_details) => trip_details,
|
||||
None => {
|
||||
return Flash::error(Redirect::to("/"), "TripDetailsId does not exist");
|
||||
}
|
||||
};
|
||||
let Some(trip_details) = TripDetails::find_by_id(db, trip_details_id).await else {
|
||||
return Flash::error(Redirect::to("/"), "TripDetailsId does not exist");
|
||||
};
|
||||
|
||||
UserTrip::delete(db, &user, &trip_details).await;
|
||||
|
||||
|
Reference in New Issue
Block a user