Skip to content

Commit d31d3fa

Browse files
authored
Fix new clippy lints. (#2935)
Signed-off-by: Shachar Langbeheim <[email protected]>
1 parent 0b0b467 commit d31d3fa

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

glide-core/redis-rs/redis/src/cluster_async/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ where
26662666
}
26672667
}
26682668

2669-
async fn calculate_topology_from_random_nodes<'a, C>(
2669+
async fn calculate_topology_from_random_nodes<C>(
26702670
inner: &Core<C>,
26712671
num_of_nodes_to_query: usize,
26722672
curr_retry: usize,

glide-core/redis-rs/redis/src/cluster_topology.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,12 @@ pub(crate) fn slot(key: &[u8]) -> u16 {
7676
}
7777

7878
fn get_hashtag(key: &[u8]) -> Option<&[u8]> {
79-
let open = key.iter().position(|v| *v == b'{');
80-
let open = match open {
81-
Some(open) => open,
82-
None => return None,
83-
};
79+
let open = key.iter().position(|v| *v == b'{')?;
8480

85-
let close = key[open..].iter().position(|v| *v == b'}');
86-
let close = match close {
87-
Some(close) => close,
88-
None => return None,
89-
};
81+
let close = key[open..].iter().position(|v| *v == b'}')?;
9082

9183
let rv = &key[open + 1..open + close];
92-
if rv.is_empty() {
93-
None
94-
} else {
95-
Some(rv)
96-
}
84+
(!rv.is_empty()).then_some(rv)
9785
}
9886

9987
/// Returns the slot that matches `key`.

glide-core/redis-rs/redis/src/sentinel.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn get_valid_replicas_addresses(
343343
}
344344

345345
#[cfg(feature = "aio")]
346-
async fn async_get_valid_replicas_addresses<'a>(
346+
async fn async_get_valid_replicas_addresses(
347347
replicas: Vec<HashMap<String, String>>,
348348
node_connection_info: &SentinelNodeConnectionInfo,
349349
) -> Vec<ConnectionInfo> {
@@ -608,15 +608,15 @@ impl Sentinel {
608608
self.async_try_all_sentinels(sentinel_masters_cmd()).await
609609
}
610610

611-
async fn async_get_sentinel_replicas<'a>(
611+
async fn async_get_sentinel_replicas(
612612
&mut self,
613-
service_name: &'a str,
613+
service_name: &str,
614614
) -> RedisResult<Vec<HashMap<String, String>>> {
615615
self.async_try_all_sentinels(sentinel_replicas_cmd(service_name))
616616
.await
617617
}
618618

619-
async fn async_find_master_address<'a>(
619+
async fn async_find_master_address(
620620
&mut self,
621621
service_name: &str,
622622
node_connection_info: &SentinelNodeConnectionInfo,
@@ -625,7 +625,7 @@ impl Sentinel {
625625
async_find_valid_master(masters, service_name, node_connection_info).await
626626
}
627627

628-
async fn async_find_valid_replica_addresses<'a>(
628+
async fn async_find_valid_replica_addresses(
629629
&mut self,
630630
service_name: &str,
631631
node_connection_info: &SentinelNodeConnectionInfo,
@@ -667,7 +667,7 @@ impl Sentinel {
667667
/// There is no guarantee that we'll actually be connecting to a different replica
668668
/// in the next call, but in a static set of replicas (no replicas added or
669669
/// removed), on average we'll choose each replica the same number of times.
670-
pub async fn async_replica_rotate_for<'a>(
670+
pub async fn async_replica_rotate_for(
671671
&mut self,
672672
service_name: &str,
673673
node_connection_info: Option<&SentinelNodeConnectionInfo>,

glide-core/redis-rs/redis/tests/test_cluster_scan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ mod test_cluster_scan_async {
11781178
for key in excepted_keys.iter() {
11791179
assert!(keys.contains(key));
11801180
}
1181-
assert!(keys.len() > 0);
1181+
assert!(!keys.is_empty());
11821182
}
11831183

11841184
#[tokio::test]

0 commit comments

Comments
 (0)