From d31d3faeff0c9c3eaf410198a06e9c20317518d0 Mon Sep 17 00:00:00 2001 From: Shachar Langbeheim Date: Sat, 11 Jan 2025 23:31:46 +0200 Subject: [PATCH] Fix new clippy lints. (#2935) Signed-off-by: Shachar Langbeheim --- .../redis-rs/redis/src/cluster_async/mod.rs | 2 +- .../redis-rs/redis/src/cluster_topology.rs | 18 +++--------------- glide-core/redis-rs/redis/src/sentinel.rs | 12 ++++++------ .../redis-rs/redis/tests/test_cluster_scan.rs | 2 +- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/glide-core/redis-rs/redis/src/cluster_async/mod.rs b/glide-core/redis-rs/redis/src/cluster_async/mod.rs index 17c983d551..3d61efce29 100644 --- a/glide-core/redis-rs/redis/src/cluster_async/mod.rs +++ b/glide-core/redis-rs/redis/src/cluster_async/mod.rs @@ -2666,7 +2666,7 @@ where } } -async fn calculate_topology_from_random_nodes<'a, C>( +async fn calculate_topology_from_random_nodes( inner: &Core, num_of_nodes_to_query: usize, curr_retry: usize, diff --git a/glide-core/redis-rs/redis/src/cluster_topology.rs b/glide-core/redis-rs/redis/src/cluster_topology.rs index b3a4a200d5..891b765a66 100644 --- a/glide-core/redis-rs/redis/src/cluster_topology.rs +++ b/glide-core/redis-rs/redis/src/cluster_topology.rs @@ -76,24 +76,12 @@ pub(crate) fn slot(key: &[u8]) -> u16 { } fn get_hashtag(key: &[u8]) -> Option<&[u8]> { - let open = key.iter().position(|v| *v == b'{'); - let open = match open { - Some(open) => open, - None => return None, - }; + let open = key.iter().position(|v| *v == b'{')?; - let close = key[open..].iter().position(|v| *v == b'}'); - let close = match close { - Some(close) => close, - None => return None, - }; + let close = key[open..].iter().position(|v| *v == b'}')?; let rv = &key[open + 1..open + close]; - if rv.is_empty() { - None - } else { - Some(rv) - } + (!rv.is_empty()).then_some(rv) } /// Returns the slot that matches `key`. diff --git a/glide-core/redis-rs/redis/src/sentinel.rs b/glide-core/redis-rs/redis/src/sentinel.rs index 569ab2fe0f..2ad5917a63 100644 --- a/glide-core/redis-rs/redis/src/sentinel.rs +++ b/glide-core/redis-rs/redis/src/sentinel.rs @@ -343,7 +343,7 @@ fn get_valid_replicas_addresses( } #[cfg(feature = "aio")] -async fn async_get_valid_replicas_addresses<'a>( +async fn async_get_valid_replicas_addresses( replicas: Vec>, node_connection_info: &SentinelNodeConnectionInfo, ) -> Vec { @@ -608,15 +608,15 @@ impl Sentinel { self.async_try_all_sentinels(sentinel_masters_cmd()).await } - async fn async_get_sentinel_replicas<'a>( + async fn async_get_sentinel_replicas( &mut self, - service_name: &'a str, + service_name: &str, ) -> RedisResult>> { self.async_try_all_sentinels(sentinel_replicas_cmd(service_name)) .await } - async fn async_find_master_address<'a>( + async fn async_find_master_address( &mut self, service_name: &str, node_connection_info: &SentinelNodeConnectionInfo, @@ -625,7 +625,7 @@ impl Sentinel { async_find_valid_master(masters, service_name, node_connection_info).await } - async fn async_find_valid_replica_addresses<'a>( + async fn async_find_valid_replica_addresses( &mut self, service_name: &str, node_connection_info: &SentinelNodeConnectionInfo, @@ -667,7 +667,7 @@ impl Sentinel { /// There is no guarantee that we'll actually be connecting to a different replica /// in the next call, but in a static set of replicas (no replicas added or /// removed), on average we'll choose each replica the same number of times. - pub async fn async_replica_rotate_for<'a>( + pub async fn async_replica_rotate_for( &mut self, service_name: &str, node_connection_info: Option<&SentinelNodeConnectionInfo>, diff --git a/glide-core/redis-rs/redis/tests/test_cluster_scan.rs b/glide-core/redis-rs/redis/tests/test_cluster_scan.rs index 96910fe7f8..fdd8877685 100644 --- a/glide-core/redis-rs/redis/tests/test_cluster_scan.rs +++ b/glide-core/redis-rs/redis/tests/test_cluster_scan.rs @@ -1178,7 +1178,7 @@ mod test_cluster_scan_async { for key in excepted_keys.iter() { assert!(keys.contains(key)); } - assert!(keys.len() > 0); + assert!(!keys.is_empty()); } #[tokio::test]