From 0314f5341f77a95422e0a488b13d67460973e080 Mon Sep 17 00:00:00 2001 From: muzarski Date: Mon, 16 Sep 2024 06:04:56 +0200 Subject: [PATCH] clippy: remove map when inspect can be used Fixing a clippy lints regarding a usage of `map()` instead of `inspect()`, when original item (closure argument) is returned from the closure. See: https://rust-lang.github.io/rust-clippy/master/index.html#/manual_inspect Unfortunately, `inspect` was introduced in rust 1.76. Our current MSRV is 1.66.0, thus we cannot use it. --- scylla-proxy/src/proxy.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scylla-proxy/src/proxy.rs b/scylla-proxy/src/proxy.rs index 7a79d7a9d1..64e0b4f317 100644 --- a/scylla-proxy/src/proxy.rs +++ b/scylla-proxy/src/proxy.rs @@ -750,20 +750,22 @@ impl Doorkeeper { desired_addr }; - socket.connect(real_addr).await.map(|ok| { + let stream = socket.connect(real_addr).await; + if let Ok(ok) = &stream { info!( "Connected to the cluster from {} at {}, intended shard {}.", ok.local_addr().unwrap(), real_addr, shard_preserving_addr.port() % shards ); - ok - }) + } + stream } else { - TcpStream::connect(real_addr).await.map(|ok| { + let stream = TcpStream::connect(real_addr).await; + if stream.is_ok() { info!("Connected to the cluster at {}.", real_addr); - ok - }) + } + stream } .map_err(|err| DoorkeeperError::NodeConnectionAttempt(real_addr, err))?;