From c7aa6454e776f0503d010af8b654a2551ac875f3 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 28 Nov 2024 23:53:20 +0100 Subject: [PATCH] Fix new clippy lints (#3054) --- axum-extra/src/extract/json_deserializer.rs | 2 +- axum-macros/src/debug_handler.rs | 7 ++----- axum-macros/src/from_request.rs | 6 +----- axum/src/extract/multipart.rs | 2 +- axum/src/json.rs | 2 +- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/axum-extra/src/extract/json_deserializer.rs b/axum-extra/src/extract/json_deserializer.rs index 4a84a72418..051ab0f1bd 100644 --- a/axum-extra/src/extract/json_deserializer.rs +++ b/axum-extra/src/extract/json_deserializer.rs @@ -202,7 +202,7 @@ fn json_content_type(headers: &HeaderMap) -> bool { }; let is_json_content_type = mime.type_() == "application" - && (mime.subtype() == "json" || mime.suffix().map_or(false, |name| name == "json")); + && (mime.subtype() == "json" || mime.suffix().is_some_and(|name| name == "json")); is_json_content_type } diff --git a/axum-macros/src/debug_handler.rs b/axum-macros/src/debug_handler.rs index 3a37c17ab3..456bd643ea 100644 --- a/axum-macros/src/debug_handler.rs +++ b/axum-macros/src/debug_handler.rs @@ -225,7 +225,7 @@ fn check_inputs_impls_from_request( state_ty: Type, kind: FunctionKind, ) -> TokenStream { - let takes_self = item_fn.sig.inputs.first().map_or(false, |arg| match arg { + let takes_self = item_fn.sig.inputs.first().is_some_and(|arg| match arg { FnArg::Receiver(_) => true, FnArg::Typed(typed) => is_self_pat_type(typed), }); @@ -604,10 +604,7 @@ fn request_consuming_type_name(ty: &Type) -> Option<&'static str> { } fn well_known_last_response_type(ty: &Type) -> Option<&'static str> { - let typename = match extract_clean_typename(ty) { - Some(tn) => tn, - None => return None, - }; + let typename = extract_clean_typename(ty)?; let type_name = match &*typename { "Json" => "Json<_>", diff --git a/axum-macros/src/from_request.rs b/axum-macros/src/from_request.rs index a6c95ab7ff..145fdad361 100644 --- a/axum-macros/src/from_request.rs +++ b/axum-macros/src/from_request.rs @@ -290,11 +290,7 @@ fn parse_single_generic_type_on_struct( let field = fields_unnamed.unnamed.first().unwrap(); if let syn::Type::Path(type_path) = &field.ty { - if type_path - .path - .get_ident() - .map_or(true, |field_type_ident| field_type_ident != ty_ident) - { + if type_path.path.get_ident() != Some(ty_ident) { return Err(syn::Error::new_spanned( type_path, format_args!( diff --git a/axum/src/extract/multipart.rs b/axum/src/extract/multipart.rs index 57d32f7563..9f278f6d25 100644 --- a/axum/src/extract/multipart.rs +++ b/axum/src/extract/multipart.rs @@ -117,7 +117,7 @@ impl Stream for Field<'_> { } } -impl<'a> Field<'a> { +impl Field<'_> { /// The field name found in the /// [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) /// header. diff --git a/axum/src/json.rs b/axum/src/json.rs index d11419a2c7..7082ac8bc3 100644 --- a/axum/src/json.rs +++ b/axum/src/json.rs @@ -132,7 +132,7 @@ fn json_content_type(headers: &HeaderMap) -> bool { }; let is_json_content_type = mime.type_() == "application" - && (mime.subtype() == "json" || mime.suffix().map_or(false, |name| name == "json")); + && (mime.subtype() == "json" || mime.suffix().is_some_and(|name| name == "json")); is_json_content_type }