Skip to content

Commit

Permalink
Appease lord clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
randomairborne committed Apr 6, 2024
1 parent 8af07a0 commit 497a647
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
#![allow(clippy::useless_let_if_seq)]

use std::{
fmt::{Display, Formatter},
Expand Down Expand Up @@ -215,14 +216,11 @@ impl<S> FromRequestParts<S> for XForwardedSsl {
type Rejection = Error;

async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
let has_ssl = match parts
let header_bytes = parts
.headers
.get("X-Forwarded-SSL")
.map(HeaderValue::as_bytes)
{
Some(b"on") => true,
_ => false,
};
.map(HeaderValue::as_bytes);
let has_ssl = matches!(header_bytes, Some(b"on"));
Ok(Self(has_ssl))
}
}
Expand All @@ -235,11 +233,10 @@ impl<S> FromRequestParts<S> for Accept {
type Rejection = Error;

async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
if let Some(v) = parts.headers.get("Accept") {
Ok(Self(v.to_str().unwrap_or("").to_string()))
} else {
Ok(Self(String::new()))
}
parts.headers.get("Accept").map_or_else(
|| Ok(Self(String::new())),
|v| Ok(Self(v.to_str().unwrap_or("").to_string())),
)
}
}

Expand Down

0 comments on commit 497a647

Please sign in to comment.