Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make `toggle` method accept `impl Into<Option<bool>>` (#3446)
Marshall Bowersdf5de47a7866
diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rsindex 62a4dffbfd2..3f99fea3156 100644--- a/crates/collab_ui2/src/collab_panel.rs+++ b/crates/collab_ui2/src/collab_panel.rs@@ -2505,7 +2505,7 @@ impl CollabPanel {.when_some(button, |el, button| el.right_button(button)).selected(is_selected).when(can_collapse, |el| {- el.toggle(Some(is_collapsed)).on_toggle(+ el.toggle(is_collapsed).on_toggle(cx.listener(move |this, _, cx| this.toggle_section_expanded(section, cx)),)});diff --git a/crates/ui2/src/components/disclosure.rs b/crates/ui2/src/components/disclosure.rsindex b3736f36a00..103c3112dfa 100644--- a/crates/ui2/src/components/disclosure.rs+++ b/crates/ui2/src/components/disclosure.rs@@ -34,10 +34,9 @@ impl RenderOnce for Disclosure {fn render(self, _cx: &mut WindowContext) -> Self::Rendered {IconButton::new("toggle",- if self.is_open {- Icon::ChevronDown- } else {- Icon::ChevronRight+ match self.is_open {+ true => Icon::ChevronDown,+ false => Icon::ChevronRight,},).color(Color::Muted)diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rsindex f5eb2eb44bf..aafd0453914 100644--- a/crates/ui2/src/components/list.rs+++ b/crates/ui2/src/components/list.rs@@ -44,8 +44,8 @@ impl List {self}- pub fn toggle(mut self, toggle: Option<bool>) -> Self {- self.toggle = toggle;+ pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {+ self.toggle = toggle.into();self}}diff --git a/crates/ui2/src/components/list/list_header.rs b/crates/ui2/src/components/list/list_header.rsindex a205de62206..7eacaef920f 100644--- a/crates/ui2/src/components/list/list_header.rs+++ b/crates/ui2/src/components/list/list_header.rs@@ -36,8 +36,8 @@ impl ListHeader {}}- pub fn toggle(mut self, toggle: Option<bool>) -> Self {- self.toggle = toggle;+ pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {+ self.toggle = toggle.into();self}diff --git a/crates/ui2/src/components/list/list_item.rs b/crates/ui2/src/components/list/list_item.rsindex d8630289a79..34a9844eaf4 100644--- a/crates/ui2/src/components/list/list_item.rs+++ b/crates/ui2/src/components/list/list_item.rs@@ -70,8 +70,8 @@ impl ListItem {self}- pub fn toggle(mut self, toggle: Option<bool>) -> Self {- self.toggle = toggle;+ pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {+ self.toggle = toggle.into();self}