From 8b5dd99d7fba5acca391810152f5538c741accf2 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 17 Jan 2024 07:48:30 -0500 Subject: [PATCH] clippy --- server_fn/src/error.rs | 2 +- server_fn/src/lib.rs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server_fn/src/error.rs b/server_fn/src/error.rs index 5352a8d598..fa84d9128c 100644 --- a/server_fn/src/error.rs +++ b/server_fn/src/error.rs @@ -10,7 +10,7 @@ use thiserror::Error; use url::Url; /// A custom header that can be used to indicate a server function returned an error. -pub const SERVER_FN_ERROR_HEADER: &'static str = "serverfnerror"; +pub const SERVER_FN_ERROR_HEADER: &str = "serverfnerror"; /// This is a result type into which any error can be converted, /// and which can be used directly in your `view`. diff --git a/server_fn/src/lib.rs b/server_fn/src/lib.rs index d8cb5a4919..b51506b3af 100644 --- a/server_fn/src/lib.rs +++ b/server_fn/src/lib.rs @@ -125,7 +125,9 @@ use codec::{Encoding, FromReq, FromRes, IntoReq, IntoRes}; pub use const_format; use dashmap::DashMap; pub use error::ServerFnError; -use error::{ServerFnErrorSerde, ServerFnUrlError}; +use error::ServerFnErrorSerde; +#[cfg(feature = "form-redirects")] +use error::ServerFnUrlError; use http::Method; use middleware::{Layer, Service}; use once_cell::sync::Lazy; @@ -240,16 +242,17 @@ where // Server functions can either be called by a real Client, // or directly by an HTML
. If they're accessed by a , default to // redirecting back to the Referer. - let accepts_html = if cfg!(feature = "form-redirects") { - req.accepts() - .map(|n| n.contains("text/html")) - .unwrap_or(false) - } else { - false - }; + #[cfg(feature = "form-redirects")] + let accepts_html = req + .accepts() + .map(|n| n.contains("text/html")) + .unwrap_or(false); + #[cfg(feature = "form-redirects")] let mut referer = req.referer().as_deref().map(ToOwned::to_owned); async move { + #[allow(unused_variables, unused_mut)] + // used in form redirects feature let (mut res, err) = Self::execute_on_server(req) .await .map(|res| (res, None))