]> OzVa Git service - ozva-cloud/commitdiff
chore: cargo clippy
authorsigoden <sigoden@gmail.com>
Thu, 10 Nov 2022 07:38:35 +0000 (15:38 +0800)
committersigoden <sigoden@gmail.com>
Thu, 10 Nov 2022 07:38:35 +0000 (15:38 +0800)
src/auth.rs
src/server.rs
src/tls.rs
tests/tls.rs

index ab2cd7b6d09d64e40aa5c10ac6aeec2f4dd5cd6d..533de3209f45256ec147bb1c38a5749bdb17c01f 100644 (file)
@@ -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":");
index 6fd16acea474c927af5c2d008fefa62f24bba9c5..e6ed1ff949419c50845bc3f6f80b198d01a7a860 100644 (file)
@@ -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<Path>>(&self, path: &'a P) -> Option<&'a Path> {
index 92b0caa52a109ab45d77f99d09af70bede4d23bc..5b11abc8b6493b035646c844f14ed6c25ce4480d 100644 (file)
@@ -125,8 +125,8 @@ impl Accept for TlsAcceptor {
 // Load public certificate from file.
 pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error::Error>> {
     // 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<Vec<Certificate>, Box<dyn std::error
 
 // Load private key from file.
 pub fn load_private_key(filename: &str) -> Result<PrivateKey, Box<dyn std::error::Error>> {
-    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.
index 4f83c909456afae405dfe4c67baf52f01d84331c..53dc60f3ea7f3807d657e11af9ad2c22a76e3515 100644 (file)
@@ -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`"));