Skip to content

Commit f7f2bf6

Browse files
committed
feat: some clippy warnings
1 parent c63b549 commit f7f2bf6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ dev:
3434
@cargo make --makefile Makefile.toml watch
3535
.PHONY: dev
3636

37+
lint:
38+
@rustc -vV
39+
@cargo clippy --all-features -- -D warnings
40+
.PHONY: lint
41+
3742
build:
3843
@rustc -vV
3944
@cargo build --release --target $(PKG_TARGET)

src/core/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const CACHE_EXT_ONE_YEAR: [&str; 30] = [
88
/// It applies the corresponding Cache-Control headers based on a set of file types.
99
pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs::File> {
1010
// Default max-age value in seconds (one day)
11-
let mut max_age = 60 * 60 * 24 as u64;
11+
let mut max_age = 60 * 60 * 24_u64;
1212

1313
if let Some(ext) = res.path().extension() {
1414
if let Some(ext) = ext.to_str() {
15-
if CACHE_EXT_ONE_HOUR.iter().any(|n| *n == ext) {
15+
if CACHE_EXT_ONE_HOUR.iter().any(|x| *x == ext) {
1616
max_age = 60 * 60;
1717
} else if CACHE_EXT_ONE_YEAR.iter().any(|x| *x == ext) {
1818
max_age = 60 * 60 * 24 * 365;
@@ -34,5 +34,5 @@ pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs:
3434

3535
/// It caps a duration value at ~136 years.
3636
fn duration(n: u64) -> u32 {
37-
std::cmp::min(n.clone(), u32::MAX as u64) as u32
37+
std::cmp::min(n, u32::MAX as u64) as u32
3838
}

src/core/rejection.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ use warp::{Rejection, Reply};
77
pub async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible> {
88
let code = if err.is_not_found() {
99
StatusCode::NOT_FOUND
10-
} else if let Some(_) = err.find::<warp::filters::body::BodyDeserializeError>() {
10+
} else if err
11+
.find::<warp::filters::body::BodyDeserializeError>()
12+
.is_some()
13+
{
1114
StatusCode::BAD_REQUEST
12-
} else if let Some(_) = err.find::<warp::reject::MethodNotAllowed>() {
15+
} else if err.find::<warp::reject::MethodNotAllowed>().is_some() {
1316
StatusCode::METHOD_NOT_ALLOWED
1417
} else {
1518
StatusCode::INTERNAL_SERVER_ERROR

0 commit comments

Comments
 (0)