From 3505a174529ec0faa26e347070f600686f6046c7 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 26 Feb 2025 21:33:25 -0500 Subject: [PATCH] git_ui: Combine disjoint conditions into one (#25722) This PR combines two disjoint conditions for the same value into one. This makes it so the type checker can accurately reason about the branches. Release Notes: - N/A --- crates/git_ui/src/branch_picker.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index c1e5f3b62766db207d0c6b1ed64419aa89460803..b39194953507fa1063bbf6b59f5ba5fdbc5a70f5 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -141,18 +141,16 @@ impl Render for BranchList { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { v_flex() .w(rems(self.rem_width)) - .when_some(self.picker.clone(), |div, picker| { - div.child(picker.clone()).on_mouse_down_out({ + .map(|parent| match self.picker.as_ref() { + Some(picker) => parent.child(picker.clone()).on_mouse_down_out({ let picker = picker.clone(); cx.listener(move |_, _, window, cx| { picker.update(cx, |this, cx| { this.cancel(&Default::default(), window, cx); }) }) - }) - }) - .when_none(&self.picker, |div| { - div.child( + }), + None => parent.child( h_flex() .id("branch-picker-error") .on_click( @@ -160,7 +158,7 @@ impl Render for BranchList { ) .child("Could not load branches.") .child("Click to retry"), - ) + ), }) } }