From e751bfb72dc86d0c13ef8f5e796287cf3b98d767 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Mon, 3 Apr 2023 23:11:15 +0200 Subject: [PATCH] refactor: remove needless `as_ref()` for paths on static file module --- src/static_files.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/static_files.rs b/src/static_files.rs index 0431938..3630dfa 100644 --- a/src/static_files.rs +++ b/src/static_files.rs @@ -177,7 +177,7 @@ fn suffix_file_html_metadata(file_path: &mut PathBuf) -> (&mut PathBuf, Option( ) -> Result, StatusCode> { tracing::trace!("getting metadata for file {}", file_path.display()); - match file_metadata(file_path.as_ref()) { + match file_metadata(file_path) { Ok((mut metadata, is_dir)) => { if is_dir { // Append a HTML index page by default if it's a directory path (`autoindex`) @@ -222,7 +222,7 @@ async fn composed_file_metadata<'a>( // Otherwise, just fallback to finding the index.html // and overwrite the current `meta` // Also noting that it's still a directory request - if let Ok(meta_res) = file_metadata(file_path.as_ref()) { + if let Ok(meta_res) = file_metadata(file_path) { (metadata, _) = meta_res } else { // We remove the appended index.html @@ -377,7 +377,7 @@ fn get_conditional_headers(header_list: &HeaderMap) -> Conditionals } /// Sanitizes a base/tail paths and then it returns an unified one. -fn sanitize_path(base: impl AsRef, tail: &str) -> Result { +fn sanitize_path(base: &Path, tail: &str) -> Result { let path_decoded = match percent_decode_str(tail.trim_start_matches('/')).decode_utf8() { Ok(p) => p, Err(err) => { @@ -387,7 +387,7 @@ fn sanitize_path(base: impl AsRef, tail: &str) -> Result