From 9dad419dd252a5061e86d49bc2e1c5206d073b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Wed, 10 May 2023 00:48:25 +0200 Subject: [PATCH] clippy --- rust/src/components/home.rs | 6 +++--- rust/src/components/inventory.rs | 24 ++++++++++++------------ rust/src/components/mod.rs | 2 +- rust/src/components/triplist.rs | 6 +++--- rust/src/main.rs | 16 ++++++++++------ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/rust/src/components/home.rs b/rust/src/components/home.rs index 3b78bc0..8d0d7e9 100644 --- a/rust/src/components/home.rs +++ b/rust/src/components/home.rs @@ -21,8 +21,8 @@ impl Home { } } -impl Into for Home { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: Home) -> Self { + val.doc } } diff --git a/rust/src/components/inventory.rs b/rust/src/components/inventory.rs index 10b0afc..f5083f6 100644 --- a/rust/src/components/inventory.rs +++ b/rust/src/components/inventory.rs @@ -32,9 +32,9 @@ impl Inventory { } } -impl Into for Inventory { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: Inventory) -> Self { + val.doc } } @@ -144,9 +144,9 @@ impl InventoryCategoryList { } } -impl Into for InventoryCategoryList { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: InventoryCategoryList) -> Self { + val.doc } } @@ -226,9 +226,9 @@ impl InventoryItemList { } } -impl Into for InventoryItemList { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: InventoryItemList) -> Self { + val.doc } } @@ -339,9 +339,9 @@ impl InventoryNewItemForm { } } -impl Into for InventoryNewItemForm { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: InventoryNewItemForm) -> Self { + val.doc } } // impl InventoryItemList { diff --git a/rust/src/components/mod.rs b/rust/src/components/mod.rs index 3305666..c5e4537 100644 --- a/rust/src/components/mod.rs +++ b/rust/src/components/mod.rs @@ -66,7 +66,7 @@ impl Root { Self { doc } } - pub fn to_string(self) -> String { + pub fn into_string(self) -> String { self.doc.into_string() } } diff --git a/rust/src/components/triplist.rs b/rust/src/components/triplist.rs index 4ed5a74..df5d541 100644 --- a/rust/src/components/triplist.rs +++ b/rust/src/components/triplist.rs @@ -31,8 +31,8 @@ impl TripList { } } -impl Into for TripList { - fn into(self) -> Markup { - self.doc +impl From for Markup { + fn from(val: TripList) -> Self { + val.doc } } diff --git a/rust/src/main.rs b/rust/src/main.rs index 43e886b..424b715 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -19,8 +19,6 @@ use sqlx::{ use serde::Deserialize; -use tracing_subscriber; - use futures::TryStreamExt; use uuid::{uuid, Uuid}; @@ -51,6 +49,12 @@ impl ClientState { } } +impl Default for ClientState { + fn default() -> Self { + Self::new() + } +} + #[tokio::main] async fn main() -> Result<(), sqlx::Error> { tracing_subscriber::fmt() @@ -99,7 +103,7 @@ async fn main() -> Result<(), sqlx::Error> { async fn root() -> (StatusCode, Html) { ( StatusCode::OK, - Html::from(Root::build(Home::build().into(), TopLevelPage::None).to_string()), + Html::from(Root::build(Home::build().into(), TopLevelPage::None).into_string()), ) } @@ -164,7 +168,7 @@ async fn inventory( .into(), TopLevelPage::Inventory, ) - .to_string(), + .into_string(), ), )) } @@ -188,7 +192,7 @@ async fn trips( Ok(( StatusCode::OK, - Html::from(Root::build(TripList::build(trips).into(), TopLevelPage::Trips).to_string()), + Html::from(Root::build(TripList::build(trips).into(), TopLevelPage::Trips).into_string()), )) } @@ -280,7 +284,7 @@ async fn inventory_item_delete( .bind(id.to_string()) .execute(&state.database_pool) .await - .map_err(|e| ((StatusCode::BAD_REQUEST, e.to_string())))?; + .map_err(|e| (StatusCode::BAD_REQUEST, e.to_string()))?; Ok(Redirect::to( headers