Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use `read()` over `read_with()` to improve readability in simple cases (#31263)
Joseph T. Lyons6206150e27cd
diff --git a/crates/agent/src/profile_selector.rs b/crates/agent/src/profile_selector.rsindex b6f2ea9fdbc..2c6efca139e 100644--- a/crates/agent/src/profile_selector.rs+++ b/crates/agent/src/profile_selector.rs@@ -153,13 +153,10 @@ impl Render for ProfileSelector {.map(|profile| profile.name.clone()).unwrap_or_else(|| "Unknown".into());- let configured_model = self- .thread- .read_with(cx, |thread, _cx| thread.configured_model())- .or_else(|| {- let model_registry = LanguageModelRegistry::read_global(cx);- model_registry.default_model()- });+ let configured_model = self.thread.read(cx).configured_model().or_else(|| {+ let model_registry = LanguageModelRegistry::read_global(cx);+ model_registry.default_model()+ });let supports_tools =configured_model.map_or(false, |default| default.model.supports_tools());diff --git a/crates/collab_ui/src/notifications/project_shared_notification.rs b/crates/collab_ui/src/notifications/project_shared_notification.rsindex f80a5e561ea..b21a2dfcb7a 100644--- a/crates/collab_ui/src/notifications/project_shared_notification.rs+++ b/crates/collab_ui/src/notifications/project_shared_notification.rs@@ -109,9 +109,7 @@ impl ProjectSharedNotification {}fn dismiss(&mut self, cx: &mut Context<Self>) {- if let Some(active_room) =- ActiveCall::global(cx).read_with(cx, |call, _| call.room().cloned())- {+ if let Some(active_room) = ActiveCall::global(cx).read(cx).room().cloned() {active_room.update(cx, |_, cx| {cx.emit(room::Event::RemoteProjectInvitationDiscarded {project_id: self.project_id,diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rsindex 079d91f182c..82d743b71dc 100644--- a/crates/debugger_ui/src/debugger_panel.rs+++ b/crates/debugger_ui/src/debugger_panel.rs@@ -349,9 +349,7 @@ impl DebugPanel {window: &mut Window,cx: &mut Context<Self>,) {- while let Some(parent_session) =- curr_session.read_with(cx, |session, _| session.parent_session().cloned())- {+ while let Some(parent_session) = curr_session.read(cx).parent_session().cloned() {curr_session = parent_session;}diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rsindex bcbe5418a4a..0f1c078b638 100644--- a/crates/multi_buffer/src/multi_buffer.rs+++ b/crates/multi_buffer/src/multi_buffer.rs@@ -1121,10 +1121,10 @@ impl MultiBuffer {pub fn last_transaction_id(&self, cx: &App) -> Option<TransactionId> {if let Some(buffer) = self.as_singleton() {- return buffer.read_with(cx, |b, _| {- b.peek_undo_stack()- .map(|history_entry| history_entry.transaction_id())- });+ return buffer+ .read(cx)+ .peek_undo_stack()+ .map(|history_entry| history_entry.transaction_id());} else {let last_transaction = self.history.undo_stack.last()?;return Some(last_transaction.id);diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rsindex 92cf2ff4567..58cdbda3990 100644--- a/crates/remote_server/src/headless_project.rs+++ b/crates/remote_server/src/headless_project.rs@@ -536,7 +536,7 @@ impl HeadlessProject {});}- let buffer_id = buffer.read_with(cx, |b, _| b.remote_id());+ let buffer_id = buffer.read(cx).remote_id();buffer_store.update(cx, |buffer_store, cx| {buffer_store