Skip to content

Commit

Permalink
Fix new clippy lints. (#2935)
Browse files Browse the repository at this point in the history
Signed-off-by: Shachar Langbeheim <[email protected]>
  • Loading branch information
nihohit authored Jan 11, 2025
1 parent 0b0b467 commit d31d3fa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion glide-core/redis-rs/redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,7 @@ where
}
}

async fn calculate_topology_from_random_nodes<'a, C>(
async fn calculate_topology_from_random_nodes<C>(
inner: &Core<C>,
num_of_nodes_to_query: usize,
curr_retry: usize,
Expand Down
18 changes: 3 additions & 15 deletions glide-core/redis-rs/redis/src/cluster_topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
12 changes: 6 additions & 6 deletions glide-core/redis-rs/redis/src/sentinel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<String, String>>,
node_connection_info: &SentinelNodeConnectionInfo,
) -> Vec<ConnectionInfo> {
Expand Down Expand Up @@ -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<Vec<HashMap<String, String>>> {
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,
Expand All @@ -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,
Expand Down Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion glide-core/redis-rs/redis/tests/test_cluster_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit d31d3fa

Please sign in to comment.