From 1d52ccd9a50daa6808c2eaf2c3daf260b83f6f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:59:35 +0800 Subject: [PATCH] chore: lint code --- crates/api_admin/src/routes/block_url.rs | 2 +- crates/feed/src/user_feed.rs | 4 ++-- crates/frontend/src/pages/home.rs | 4 ++-- crates/frontend/src/pages/mod.rs | 1 - crates/frontend/src/partials/layout.rs | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/api_admin/src/routes/block_url.rs b/crates/api_admin/src/routes/block_url.rs index b2c7002..fd1b27e 100644 --- a/crates/api_admin/src/routes/block_url.rs +++ b/crates/api_admin/src/routes/block_url.rs @@ -28,7 +28,7 @@ pub async fn block_url( ) -> Result<(StatusCode, Json), AppError> { match &query.url { url if url.query().is_some() => Err(AppError::new( - format!("wrong url: {} (can't contain search params)", url), + format!("wrong url: {url} (can't contain search params)"), None, Some(StatusCode::BAD_REQUEST), )), diff --git a/crates/feed/src/user_feed.rs b/crates/feed/src/user_feed.rs index f4f52ca..5f63f19 100644 --- a/crates/feed/src/user_feed.rs +++ b/crates/feed/src/user_feed.rs @@ -105,8 +105,8 @@ impl UserFeed { match self { Self { json: Some(url), .. - } => UserFeedTopLevel::parse_json_feed(url.clone()).await, - Self { + } + | Self { atom: Some(url), .. } => UserFeedTopLevel::parse_xml_feed(url.clone()).await, Self { rss: Some(url), .. } => UserFeedTopLevel::parse_xml_feed(url.clone()).await, diff --git a/crates/frontend/src/pages/home.rs b/crates/frontend/src/pages/home.rs index 17d485c..a829657 100644 --- a/crates/frontend/src/pages/home.rs +++ b/crates/frontend/src/pages/home.rs @@ -9,10 +9,10 @@ pub async fn home(data: Data) -> Markup { .env .hatsu_node_name .clone() - .unwrap_or(String::from("Hatsu")); + .unwrap_or_else(|| String::from("Hatsu")); layout( - html! { + &html! { @if let Some(description) = &data.env.hatsu_node_description { h2 class="md-typescale-title-large" style="margin-top: 0" { "About this instance" } p style="margin: 0" { (description) } diff --git a/crates/frontend/src/pages/mod.rs b/crates/frontend/src/pages/mod.rs index 538298e..72890ec 100644 --- a/crates/frontend/src/pages/mod.rs +++ b/crates/frontend/src/pages/mod.rs @@ -2,7 +2,6 @@ use axum::{routing::get, Router}; mod home; -#[must_use] pub fn routes() -> Router { Router::new().route("/", get(home::home)) } diff --git a/crates/frontend/src/partials/layout.rs b/crates/frontend/src/partials/layout.rs index 3abe628..5c27040 100644 --- a/crates/frontend/src/partials/layout.rs +++ b/crates/frontend/src/partials/layout.rs @@ -37,12 +37,12 @@ document.adoptedStyleSheets.push(typescaleStyles.styleSheet); } } -pub fn layout(body: Markup, data: &Data) -> Markup { +pub fn layout(body: &Markup, data: &Data) -> Markup { let title = data .env .hatsu_node_name .clone() - .unwrap_or(String::from("Hatsu")); + .unwrap_or_else(|| String::from("Hatsu")); html! { (DOCTYPE)