Skip to content

Commit 7010852

Browse files
committed
Use let_chain instead of nested if conditions
1 parent aa69e33 commit 7010852

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/web/releases.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,13 @@ async fn get_search_results(
256256
// Categorize errors from registry
257257
fn handle_registry_error(err: anyhow::Error) -> Result<SearchResult, SearchError> {
258258
// Capture crates.io API error
259-
if let Some(registry_request_error) = err.downcast_ref::<reqwest::Error>() {
260-
if let Some(status) = registry_request_error.status() {
261-
if status.is_client_error() || status.is_server_error() {
262-
return Err(SearchError::CratesIo(format!(
263-
"crates.io returned {status}: {registry_request_error}"
264-
)));
265-
}
266-
}
259+
if let Some(registry_request_error) = err.downcast_ref::<reqwest::Error>()
260+
&& let Some(status) = registry_request_error.status()
261+
&& (status.is_client_error() || status.is_server_error())
262+
{
263+
return Err(SearchError::CratesIo(format!(
264+
"crates.io returned {status}: {registry_request_error}"
265+
)));
267266
}
268267
// Move all other error types to this wrapper
269268
Err(SearchError::Other(err))
@@ -2237,7 +2236,7 @@ mod tests {
22372236
env.fake_release()
22382237
.await
22392238
.name("failed")
2240-
.version(&format!("0.0.{}", i))
2239+
.version(&format!("0.0.{i}"))
22412240
.build_result_failed()
22422241
.create()
22432242
.await?;

0 commit comments

Comments
 (0)