From bd07783cdecb9e1d9b15b85fb41d673605669acc Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 10 Nov 2022 15:38:35 +0800 Subject: [PATCH] chore: cargo clippy --- src/auth.rs | 8 ++++---- src/server.rs | 4 ++-- src/tls.rs | 8 ++++---- tests/tls.rs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index ab2cd7b..533de32 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -216,7 +216,7 @@ impl AuthMethod { let digest_vals = to_headermap(digest_value).ok()?; digest_vals .get(b"username".as_ref()) - .and_then(|b| std::str::from_utf8(*b).ok()) + .and_then(|b| std::str::from_utf8(b).ok()) .map(|v| v.to_string()) } } @@ -255,7 +255,7 @@ impl AuthMethod { if let (Some(username), Some(nonce), Some(user_response)) = ( digest_vals .get(b"username".as_ref()) - .and_then(|b| std::str::from_utf8(*b).ok()), + .and_then(|b| std::str::from_utf8(b).ok()), digest_vals.get(b"nonce".as_ref()), digest_vals.get(b"response".as_ref()), ) { @@ -278,7 +278,7 @@ impl AuthMethod { if qop == &b"auth".as_ref() || qop == &b"auth-int".as_ref() { correct_response = Some({ let mut c = Context::new(); - c.consume(&auth_pass); + c.consume(auth_pass); c.consume(b":"); c.consume(nonce); c.consume(b":"); @@ -301,7 +301,7 @@ impl AuthMethod { Some(r) => r, None => { let mut c = Context::new(); - c.consume(&auth_pass); + c.consume(auth_pass); c.consume(b":"); c.consume(nonce); c.consume(b":"); diff --git a/src/server.rs b/src/server.rs index 6fd16ac..e6ed1ff 100644 --- a/src/server.rs +++ b/src/server.rs @@ -593,7 +593,7 @@ impl Server { None }; - if let Some(mime) = mime_guess::from_path(&path).first() { + if let Some(mime) = mime_guess::from_path(path).first() { res.headers_mut().typed_insert(ContentType::from(mime)); } else { res.headers_mut().insert( @@ -902,7 +902,7 @@ impl Server { Some(path) => path, None => return None, }; - Some(self.args.path.join(&stripped_path)) + Some(self.args.path.join(stripped_path)) } fn strip_path_prefix<'a, P: AsRef>(&self, path: &'a P) -> Option<&'a Path> { diff --git a/src/tls.rs b/src/tls.rs index 92b0caa..5b11abc 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -125,8 +125,8 @@ impl Accept for TlsAcceptor { // Load public certificate from file. pub fn load_certs(filename: &str) -> Result, Box> { // Open certificate file. - let cert_file = fs::File::open(&filename) - .map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; + let cert_file = + fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; let mut reader = io::BufReader::new(cert_file); // Load and return certificate. @@ -139,8 +139,8 @@ pub fn load_certs(filename: &str) -> Result, Box Result> { - let key_file = fs::File::open(&filename) - .map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; + let key_file = + fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; let mut reader = io::BufReader::new(key_file); // Load and return a single private key. diff --git a/tests/tls.rs b/tests/tls.rs index 4f83c90..53dc60f 100644 --- a/tests/tls.rs +++ b/tests/tls.rs @@ -34,7 +34,7 @@ fn tls_works(#[case] server: TestServer) -> Result<(), Error> { #[rstest] fn wrong_path_cert() -> Result<(), Error> { Command::cargo_bin("dufs")? - .args(&["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"]) + .args(["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"]) .assert() .failure() .stderr(contains("error: Failed to access `wrong`")); @@ -46,7 +46,7 @@ fn wrong_path_cert() -> Result<(), Error> { #[rstest] fn wrong_path_key() -> Result<(), Error> { Command::cargo_bin("dufs")? - .args(&["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"]) + .args(["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"]) .assert() .failure() .stderr(contains("error: Failed to access `wrong`"));