Format let-else statements

This commit is contained in:
Max Brunsfeld 2023-08-25 10:11:32 -07:00
parent 732af201dc
commit 404f76739c
28 changed files with 210 additions and 109 deletions

View file

@ -249,7 +249,9 @@ impl Database {
let mut tx = Arc::new(Some(tx));
let result = f(TransactionHandle(tx.clone())).await;
let Some(tx) = Arc::get_mut(&mut tx).and_then(|tx| tx.take()) else {
return Err(anyhow!("couldn't complete transaction because it's still in use"))?;
return Err(anyhow!(
"couldn't complete transaction because it's still in use"
))?;
};
Ok((tx, result))

View file

@ -465,9 +465,9 @@ impl Database {
let mut rejoined_projects = Vec::new();
for rejoined_project in &rejoin_room.rejoined_projects {
let project_id = ProjectId::from_proto(rejoined_project.id);
let Some(project) = project::Entity::find_by_id(project_id)
.one(&*tx)
.await? else { continue };
let Some(project) = project::Entity::find_by_id(project_id).one(&*tx).await? else {
continue;
};
let mut worktrees = Vec::new();
let db_worktrees = project.find_related(worktree::Entity).all(&*tx).await?;

View file

@ -121,7 +121,9 @@ async fn test_random_collaboration(
let mut operation_channels = Vec::new();
loop {
let Some((next_operation, applied)) = plan.lock().next_server_operation(&clients) else { break };
let Some((next_operation, applied)) = plan.lock().next_server_operation(&clients) else {
break;
};
applied.store(true, SeqCst);
let did_apply = apply_server_operation(
deterministic.clone(),
@ -224,7 +226,9 @@ async fn apply_server_operation(
let client_ix = clients
.iter()
.position(|(client, cx)| client.current_user_id(cx) == removed_user_id);
let Some(client_ix) = client_ix else { return false };
let Some(client_ix) = client_ix else {
return false;
};
let user_connection_ids = server
.connection_pool
.lock()
@ -1591,10 +1595,11 @@ impl TestPlan {
81.. => match self.rng.gen_range(0..100_u32) {
// Add a worktree to a local project
0..=50 => {
let Some(project) = client
.local_projects()
.choose(&mut self.rng)
.cloned() else { continue };
let Some(project) =
client.local_projects().choose(&mut self.rng).cloned()
else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let mut paths = client.fs().paths(false);
paths.remove(0);
@ -1611,7 +1616,9 @@ impl TestPlan {
// Add an entry to a worktree
_ => {
let Some(project) = choose_random_project(client, &mut self.rng) else { continue };
let Some(project) = choose_random_project(client, &mut self.rng) else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let is_local = project.read_with(cx, |project, _| project.is_local());
let worktree = project.read_with(cx, |project, cx| {
@ -1645,7 +1652,9 @@ impl TestPlan {
// Query and mutate buffers
60..=90 => {
let Some(project) = choose_random_project(client, &mut self.rng) else { continue };
let Some(project) = choose_random_project(client, &mut self.rng) else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let is_local = project.read_with(cx, |project, _| project.is_local());
@ -1656,7 +1665,10 @@ impl TestPlan {
.buffers_for_project(&project)
.iter()
.choose(&mut self.rng)
.cloned() else { continue };
.cloned()
else {
continue;
};
let full_path = buffer
.read_with(cx, |buffer, cx| buffer.file().unwrap().full_path(cx));
@ -2026,7 +2038,10 @@ async fn simulate_client(
client.app_state.languages.add(Arc::new(language));
while let Some(batch_id) = operation_rx.next().await {
let Some((operation, applied)) = plan.lock().next_client_operation(&client, batch_id, &cx) else { break };
let Some((operation, applied)) = plan.lock().next_client_operation(&client, batch_id, &cx)
else {
break;
};
applied.store(true, SeqCst);
match apply_client_operation(&client, operation, &mut cx).await {
Ok(()) => {}