Skip to content

Commit

Permalink
Fix new clippy lints (#3054)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored Nov 28, 2024
1 parent 11806fb commit c7aa645
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion axum-extra/src/extract/json_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 2 additions & 5 deletions axum-macros/src/debug_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down Expand Up @@ -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<_>",
Expand Down
6 changes: 1 addition & 5 deletions axum-macros/src/from_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion axum/src/extract/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion axum/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c7aa645

Please sign in to comment.