Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove when_else
Joseph T. Lyons7c19650a4065
diff --git a/crates/feedback2/src/feedback_modal.rs b/crates/feedback2/src/feedback_modal.rsindex 68fbcfb3a30..583d31ce5d3 100644--- a/crates/feedback2/src/feedback_modal.rs+++ b/crates/feedback2/src/feedback_modal.rs@@ -319,10 +319,12 @@ impl Render for FeedbackModal {"Characters: {}",characters_remaining))- .when_else(- valid_character_count,- |this| this.color(Color::Success),- |this| this.color(Color::Error)+ .color(+ if valid_character_count {+ Color::Success+ } else {+ Color::Error+ })),)@@ -349,11 +351,13 @@ impl Render for FeedbackModal {.color(Color::Muted)// TODO: replicate this logic when clicking outside the modal// TODO: Will require somehow overriding the modal dismal default behavior- .when_else(- has_feedback,- |this| this.on_click(dismiss_prompt),- |this| this.on_click(dismiss)- )+ .map(|this| {+ if has_feedback {+ this.on_click(dismiss_prompt)+ } else {+ this.on_click(dismiss)+ }+ })).child(Button::new("send_feedback", submit_button_text)diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rsindex a67276b0bcd..226a477012a 100644--- a/crates/gpui2/src/element.rs+++ b/crates/gpui2/src/element.rs@@ -69,24 +69,6 @@ pub trait IntoElement: Sized {self.map(|this| if condition { then(this) } else { this })}- fn when_else(- self,- condition: bool,- then: impl FnOnce(Self) -> Self,- otherwise: impl FnOnce(Self) -> Self,- ) -> Self- where- Self: Sized,- {- self.map(|this| {- if condition {- then(this)- } else {- otherwise(this)- }- })- }-fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> SelfwhereSelf: Sized,diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rsindex 29586fd1941..8314f607fef 100644--- a/crates/ui2/src/components/keybinding.rs+++ b/crates/ui2/src/components/keybinding.rs@@ -98,11 +98,13 @@ impl RenderOnce for Key {div().py_0()- .when_else(- single_char,- |el| el.w(rems(14. / 16.)).flex().flex_none().justify_center(),- |el| el.px_0p5(),- )+ .map(|this| {+ if single_char {+ this.w(rems(14. / 16.)).flex().flex_none().justify_center()+ } else {+ this.px_0p5()+ }+ }).h(rems(14. / 16.)).text_ui().line_height(relative(1.))