diff --git a/rosenpass/src/cli.rs b/rosenpass/src/cli.rs index 86cee92..7b1a7d4 100644 --- a/rosenpass/src/cli.rs +++ b/rosenpass/src/cli.rs @@ -138,7 +138,7 @@ impl Cli { // Manual arg parsing, since clap wants to prefix flags with "--" let mut args = args.into_iter(); loop { - match (args.next().as_ref().map(String::as_str), args.next()) { + match (args.next().as_deref(), args.next()) { (Some("private-key"), Some(opt)) | (Some("secret-key"), Some(opt)) => { secret_key = Some(opt.into()); } diff --git a/rosenpass/src/config.rs b/rosenpass/src/config.rs index 8eee049..c61c62e 100644 --- a/rosenpass/src/config.rs +++ b/rosenpass/src/config.rs @@ -374,7 +374,7 @@ mod test { use super::*; fn split_str(s: &str) -> Vec { - s.split(" ").map(|s| s.to_string()).collect() + s.split(' ').map(|s| s.to_string()).collect() } #[test] diff --git a/rosenpass/src/protocol.rs b/rosenpass/src/protocol.rs index c541d60..9605d00 100644 --- a/rosenpass/src/protocol.rs +++ b/rosenpass/src/protocol.rs @@ -1770,14 +1770,10 @@ mod test { // Process the entire handshake let mut msglen = Some(me.initiate_handshake(PEER0, &mut *resbuf).unwrap()); - loop { - if let Some(l) = msglen { - std::mem::swap(&mut me, &mut they); - std::mem::swap(&mut msgbuf, &mut resbuf); - msglen = test_incorrect_sizes_for_msg(&mut me, &*msgbuf, l, &mut *resbuf); - } else { - break; - } + while let Some(l) = msglen { + std::mem::swap(&mut me, &mut they); + std::mem::swap(&mut msgbuf, &mut resbuf); + msglen = test_incorrect_sizes_for_msg(&mut me, &*msgbuf, l, &mut *resbuf); } assert_eq!( @@ -1804,8 +1800,8 @@ mod test { } let res = srv.handle_msg(&msgbuf[..l], resbuf); - assert!(matches!(res, Err(_))); // handle_msg should raise an error - assert!(!resbuf.iter().find(|x| **x != 0).is_some()); // resbuf should not have been changed + assert!(res.is_err()); // handle_msg should raise an error + assert!(!resbuf.iter().any(|x| *x != 0)); // resbuf should not have been changed } // Apply the proper handle_msg operation diff --git a/rosenpass/tests/integration_test.rs b/rosenpass/tests/integration_test.rs index a953d66..e786df3 100644 --- a/rosenpass/tests/integration_test.rs +++ b/rosenpass/tests/integration_test.rs @@ -30,11 +30,8 @@ fn generate_keys() { fn find_udp_socket() -> u16 { for port in 1025..=u16::MAX { - match UdpSocket::bind(("127.0.0.1", port)) { - Ok(_) => { - return port; - } - _ => {} + if UdpSocket::bind(("127.0.0.1", port)).is_ok() { + return port; } } panic!("no free UDP port found"); @@ -54,9 +51,9 @@ fn check_exchange() { for (secret_key_path, pub_key_path) in secret_key_paths.iter().zip(public_key_paths.iter()) { let output = test_bin::get_test_bin(BIN) .args(["gen-keys", "--secret-key"]) - .arg(&secret_key_path) + .arg(secret_key_path) .arg("--public-key") - .arg(&pub_key_path) + .arg(pub_key_path) .output() .expect("Failed to start {BIN}");