From ce17b74cbf616103d779c4b133840cc75c2ee570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Tue, 29 Aug 2023 21:34:01 +0200 Subject: [PATCH] clippy --- rust/src/lib.rs | 6 +++--- rust/src/models/inventory.rs | 2 +- rust/src/routing/routes.rs | 14 ++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index db8d595..8b9a446 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -64,9 +64,9 @@ impl fmt::Display for UriPath { } } -impl<'a> Into<&'a str> for &'a UriPath { - fn into(self) -> &'a str { - self.0.as_str() +impl<'a> From<&'a UriPath> for &'a str { + fn from(val: &'a UriPath) -> Self { + val.0.as_str() } } diff --git a/rust/src/models/inventory.rs b/rust/src/models/inventory.rs index d5702ff..21ea011 100644 --- a/rust/src/models/inventory.rs +++ b/rust/src/models/inventory.rs @@ -29,7 +29,7 @@ impl Inventory { .collect::, Error>>()?; for category in &mut categories { - category.populate_items(&ctx, &pool).await?; + category.populate_items(ctx, pool).await?; } Ok(Self { categories }) diff --git a/rust/src/routing/routes.rs b/rust/src/routing/routes.rs index 08ccec5..ce5149c 100644 --- a/rust/src/routing/routes.rs +++ b/rust/src/routing/routes.rs @@ -450,12 +450,10 @@ pub async fn trip_edit_attribute( Form(trip_update): Form, ) -> Result { let ctx = Context::build(current_user); - if attribute == models::trips::TripAttribute::Name { - if trip_update.new_value.is_empty() { - return Err(Error::Request(RequestError::EmptyFormElement { - name: "name".to_string(), - })); - } + if attribute == models::trips::TripAttribute::Name && trip_update.new_value.is_empty() { + return Err(Error::Request(RequestError::EmptyFormElement { + name: "name".to_string(), + })); } models::trips::Trip::set_attribute( &ctx, @@ -477,7 +475,7 @@ pub async fn trip_item_set_state( key: models::trips::TripItemStateKey, value: bool, ) -> Result<(), Error> { - models::trips::TripItem::set_state(&ctx, &state.database_pool, trip_id, item_id, key, value) + models::trips::TripItem::set_state(ctx, &state.database_pool, trip_id, item_id, key, value) .await?; Ok(()) } @@ -500,7 +498,7 @@ pub async fn trip_row( trip_id, &item, models::inventory::InventoryItem::get_category_max_weight( - &ctx, + ctx, &state.database_pool, item.item.category_id, )