From 2b0c661f03d629855a4dcc7dd32ffa693b6a5b25 Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Mon, 14 Nov 2022 23:35:30 -0800 Subject: [PATCH] refactor: Fix most clippy lints --- src/bundle/rundir.rs | 2 +- src/files/directory/listing.rs | 2 +- src/files/named_ext.rs | 2 +- src/files/path.rs | 4 ++-- src/files/service.rs | 2 +- src/monitor.rs | 2 +- src/server.rs | 9 ++++----- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/bundle/rundir.rs b/src/bundle/rundir.rs index 5574040..bb79119 100644 --- a/src/bundle/rundir.rs +++ b/src/bundle/rundir.rs @@ -175,7 +175,7 @@ impl RunDir { pathbuf.push(name); if let Some(parent) = pathbuf.parent() { - if PathBuf::from(parent) != PathBuf::from(&self.path) { + if *parent != self.path { return Err(Error::InvalidSubDirName { name: String::from(name), inner_error: None, diff --git a/src/files/directory/listing.rs b/src/files/directory/listing.rs index 19d49a9..2ad0eb0 100644 --- a/src/files/directory/listing.rs +++ b/src/files/directory/listing.rs @@ -38,7 +38,7 @@ pub fn default_listing_renderer( if dir.is_visible(&entry) { let entry = entry.unwrap(); let p = match entry.path().strip_prefix(&dir.path) { - Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace("\\", "/"), + Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace('\\', "/"), Ok(p) => base.join(p).to_string_lossy().into_owned(), Err(_) => continue, }; diff --git a/src/files/named_ext.rs b/src/files/named_ext.rs index fe2be1a..7492ab1 100644 --- a/src/files/named_ext.rs +++ b/src/files/named_ext.rs @@ -12,7 +12,7 @@ impl NamedFileExt for NamedFile { let mut this = self; if let Some(mime_disposition) = path_context.get_mime_disposition() { - if let Some(new_disposition_type) = mime_disposition.get(&this.content_type()) { + if let Some(new_disposition_type) = mime_disposition.get(this.content_type()) { let original_parameters = this.content_disposition().parameters.clone(); this = this.set_content_disposition(ContentDisposition { diff --git a/src/files/path.rs b/src/files/path.rs index e0fb0b7..c5a8d20 100644 --- a/src/files/path.rs +++ b/src/files/path.rs @@ -36,7 +36,7 @@ pub fn resolve_path_within_tree( .ok_or(Error::NoParent)? }; - Ok(new_path.canonicalize().context(Canonicalize { + new_path.canonicalize().context(Canonicalize { path: new_path.clone(), - })?) + }) } diff --git a/src/files/service.rs b/src/files/service.rs index ff4c332..00dd12a 100644 --- a/src/files/service.rs +++ b/src/files/service.rs @@ -359,7 +359,7 @@ impl FilesServiceInner { let (http_req, _payload) = req.into_parts(); let mut response = named_file - .with_path_context(&path_context) + .with_path_context(path_context) .into_response(&http_req); path_context.append_headers_to_map(response.headers_mut()); diff --git a/src/monitor.rs b/src/monitor.rs index c61da8a..d69aafc 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -159,7 +159,7 @@ impl Monitor { } for thread_id in thread_ids { - if let Some(thread) = state.panicked.get(&thread_id) { + if let Some(thread) = state.panicked.get(thread_id) { watched_panicked.push(thread.clone().clone()); } } diff --git a/src/server.rs b/src/server.rs index 00e9e9f..65e5b8e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -68,11 +68,10 @@ impl Server { let serve_dir = Arc::clone(&self.serve_dir); let redirect_to_slash = self.config.redirect_to_slash; - let enable_auto_compression = match self.config.compression { - Some(CompressionConfig::Auto) => true, - None => true, - _ => false, - }; + let enable_auto_compression = matches!( + self.config.compression, + Some(CompressionConfig::Auto) | None + ); let root_path_context = Arc::new(PathContext::try_from(&self.config).context(CreatePathContext)?); -- GitLab