ui2: Clean up `take`s

Marshall Bowers created

Change summary

crates/ui2/src/components/list.rs    | 6 +++---
crates/ui2/src/components/modal.rs   | 6 +++---
crates/ui2/src/components/palette.rs | 4 ++--
crates/ui2/src/elements/details.rs   | 4 ++--
4 files changed, 10 insertions(+), 10 deletions(-)

Detailed changes

crates/ui2/src/components/list.rs 🔗

@@ -250,7 +250,7 @@ impl<S: 'static> ListItem<S> {
 pub struct ListEntry {
     disclosure_control_style: DisclosureControlVisibility,
     indent_level: u32,
-    label: Option<Label>,
+    label: Label,
     left_content: Option<LeftContent>,
     variant: ListItemVariant,
     size: ListEntrySize,
@@ -264,7 +264,7 @@ impl ListEntry {
         Self {
             disclosure_control_style: DisclosureControlVisibility::default(),
             indent_level: 0,
-            label: Some(label),
+            label,
             variant: ListItemVariant::default(),
             left_content: None,
             size: ListEntrySize::default(),
@@ -412,7 +412,7 @@ impl ListEntry {
                     .relative()
                     .children(self.disclosure_control(cx))
                     .children(left_content)
-                    .children(self.label.take()),
+                    .child(self.label),
             )
     }
 }

crates/ui2/src/components/modal.rs 🔗

@@ -38,7 +38,7 @@ impl<S: 'static> Modal<S> {
         self
     }
 
-    fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
+    fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
         let theme = theme(cx);
 
         v_stack()
@@ -68,8 +68,8 @@ impl<S: 'static> Modal<S> {
                             .border_color(theme.border)
                             .p_1()
                             .justify_end()
-                            .children(self.secondary_action.take())
-                            .children(self.primary_action.take()),
+                            .children(self.secondary_action)
+                            .children(self.primary_action),
                     )
                 },
             )

crates/ui2/src/components/palette.rs 🔗

@@ -131,7 +131,7 @@ impl PaletteItem {
         self
     }
 
-    fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
+    fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
         div()
             .flex()
             .flex_row()
@@ -142,7 +142,7 @@ impl PaletteItem {
                     .child(Label::new(self.label.clone()))
                     .children(self.sublabel.clone().map(|sublabel| Label::new(sublabel))),
             )
-            .children(self.keybinding.take())
+            .children(self.keybinding)
     }
 }
 

crates/ui2/src/elements/details.rs 🔗

@@ -26,7 +26,7 @@ impl<S: 'static> Details<S> {
         self
     }
 
-    fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
+    fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
         let theme = theme(cx);
 
         v_stack()
@@ -37,7 +37,7 @@ impl<S: 'static> Details<S> {
             .size_full()
             .child(self.text)
             .children(self.meta.map(|m| m))
-            .children(self.actions.take().map(|a| a))
+            .children(self.actions.map(|a| a))
     }
 }