Ver código fonte

Handle clippy advices.

Jing Yang 3 anos atrás
pai
commit
34573428cf
3 arquivos alterados com 10 adições e 13 exclusões
  1. 3 5
      src/network.rs
  2. 3 4
      src/server.rs
  3. 4 4
      src/test_utils/junk_server.rs

+ 3 - 5
src/network.rs

@@ -437,12 +437,10 @@ mod tests {
             "Network is running, requests should be processed."
         );
 
-        let reply = match futures::executor::block_on(rx) {
+        match futures::executor::block_on(rx) {
             Ok(reply) => reply,
             Err(e) => panic!("Future execution should not fail: {}", e),
-        };
-
-        reply
+        }
     }
 
     #[test]
@@ -581,7 +579,7 @@ mod tests {
 
         // Unblock the client, then remove the server.
         unlock(&network).set_enable_client(TEST_CLIENT, true);
-        unlock(&network).remove_server(&TEST_SERVER);
+        unlock(&network).remove_server(TEST_SERVER);
 
         // Send third request.
         let reply = futures::executor::block_on(

+ 3 - 4
src/server.rs

@@ -117,6 +117,7 @@ impl Server {
             result = result => Some(result),
             _ = this.interrupt.notified() => None,
         };
+        #[allow(clippy::let_and_return)]
         let ret = match result {
             Some(Ok(ret)) => ret,
             Some(Err(_)) => Err(std::io::Error::new(
@@ -292,8 +293,7 @@ mod tests {
 
         assert_eq!(
             reply
-                .err()
-                .expect("Aborting RPC should return error")
+                .expect_err("Aborting RPC should return error")
                 .kind(),
             std::io::ErrorKind::ConnectionReset,
         );
@@ -316,8 +316,7 @@ mod tests {
 
         assert_eq!(
             reply
-                .err()
-                .expect("Interrupted server should return error")
+                .expect_err("Interrupted server should return error")
                 .kind(),
             std::io::ErrorKind::Interrupted,
         );

+ 4 - 4
src/test_utils/junk_server.rs

@@ -2,11 +2,11 @@ use lazy_static::lazy_static;
 
 use crate::Server;
 
-pub const TEST_SERVER: &str = &"test-server";
-pub const NON_SERVER: &str = &"non-server";
+pub const TEST_SERVER: &str = "test-server";
+pub const NON_SERVER: &str = "non-server";
 
-pub const TEST_CLIENT: &str = &"test-client";
-pub const NON_CLIENT: &str = &"non-client";
+pub const TEST_CLIENT: &str = "test-client";
+pub const NON_CLIENT: &str = "non-client";
 
 pub enum JunkRpcs {
     Echo,