Skip to content

Commit cba0bec

Browse files
authored
refactor: make use of the new if let chains pattern with Rust 1.88 (#270)
Signed-off-by: Jérémy Audiger <[email protected]>
1 parent 618f21f commit cba0bec

File tree

1 file changed

+30
-31
lines changed
  • crates/brioche-core/src/project

1 file changed

+30
-31
lines changed

crates/brioche-core/src/project/load.rs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ async fn load_project_inner(
551551

552552
// Validate expected project hashes in the group
553553
for &(node, _, project_hash) in &group_project_entries {
554-
if let Some(expected_hash) = project_graph.expected_hashes.remove(&node) {
555-
if expected_hash != project_hash {
556-
errors.push(LoadProjectError::InvalidProjectHash {
557-
path: project_graph.graph[node].clone(),
558-
expected_hash: expected_hash.to_string(),
559-
actual_hash: project_hash.to_string(),
560-
});
561-
}
554+
if let Some(expected_hash) = project_graph.expected_hashes.remove(&node)
555+
&& expected_hash != project_hash
556+
{
557+
errors.push(LoadProjectError::InvalidProjectHash {
558+
path: project_graph.graph[node].clone(),
559+
expected_hash: expected_hash.to_string(),
560+
actual_hash: project_hash.to_string(),
561+
});
562562
}
563563
}
564564

@@ -587,14 +587,14 @@ async fn load_project_inner(
587587
for (node, (project_hash, project_entry, mut errors)) in nodes_to_projects {
588588
let path = &project_graph.graph[node];
589589

590-
if let Some(expected_hash) = project_graph.expected_hashes.remove(&node) {
591-
if expected_hash != project_hash {
592-
errors.push(LoadProjectError::InvalidProjectHash {
593-
path: project_graph.graph[node].clone(),
594-
expected_hash: expected_hash.to_string(),
595-
actual_hash: project_hash.to_string(),
596-
});
597-
}
590+
if let Some(expected_hash) = project_graph.expected_hashes.remove(&node)
591+
&& expected_hash != project_hash
592+
{
593+
errors.push(LoadProjectError::InvalidProjectHash {
594+
path: project_graph.graph[node].clone(),
595+
expected_hash: expected_hash.to_string(),
596+
actual_hash: project_hash.to_string(),
597+
});
598598
}
599599

600600
projects.projects.insert(project_hash, project_entry);
@@ -674,23 +674,22 @@ async fn resolve_dependency_version_to_local_path(
674674
dependency_version: &Version,
675675
current_lockfile: Option<&Lockfile>,
676676
) -> anyhow::Result<ResolvedDependency> {
677-
if let Some(workspace) = workspace {
678-
if let Some(workspace_path) =
677+
if let Some(workspace) = workspace
678+
&& let Some(workspace_path) =
679679
resolve_workspace_project_path(workspace, dependency_name).await?
680-
{
681-
// Eventually, we'll validate that the version of the project
682-
// from the workspace matches the requested dependency version
683-
match dependency_version {
684-
Version::Any => {}
685-
}
686-
687-
return Ok(ResolvedDependency {
688-
local_path: workspace_path,
689-
expected_hash: None,
690-
locking: config.locking,
691-
should_lock: None,
692-
});
680+
{
681+
// Eventually, we'll validate that the version of the project
682+
// from the workspace matches the requested dependency version
683+
match dependency_version {
684+
Version::Any => {}
693685
}
686+
687+
return Ok(ResolvedDependency {
688+
local_path: workspace_path,
689+
expected_hash: None,
690+
locking: config.locking,
691+
should_lock: None,
692+
});
694693
}
695694

696695
// TODO: Validate that the requested dependency version matches the

0 commit comments

Comments
 (0)