Remove hacky children

Marshall Bowers created

Change summary

crates/gpui3/src/element.rs                   | 25 ---------------------
crates/storybook2/src/stories/kitchen_sink.rs | 12 ++++++---
crates/storybook2/src/storybook2.rs           |  2 
crates/ui2/src/children.rs                    |  7 -----
crates/ui2/src/lib.rs                         |  2 -
crates/ui2/src/prelude.rs                     |  2 
6 files changed, 10 insertions(+), 40 deletions(-)

Detailed changes

crates/gpui3/src/element.rs 🔗

@@ -82,31 +82,6 @@ pub trait ParentElement {
             .extend(iter.into_iter().map(|item| item.into_any()));
         self
     }
-
-    // HACK: This is a temporary hack to get children working for the purposes
-    // of building UI on top of the current version of gpui2.
-    //
-    // We'll (hopefully) be moving away from this in the future.
-    fn children_any<I>(mut self, children: I) -> Self
-    where
-        I: IntoIterator<Item = AnyElement<Self::State>>,
-        Self: Sized,
-    {
-        self.children_mut().extend(children.into_iter());
-        self
-    }
-
-    // HACK: This is a temporary hack to get children working for the purposes
-    // of building UI on top of the current version of gpui2.
-    //
-    // We'll (hopefully) be moving away from this in the future.
-    fn child_any(mut self, children: AnyElement<Self::State>) -> Self
-    where
-        Self: Sized,
-    {
-        self.children_mut().push(children);
-        self
-    }
 }
 
 trait ElementObject<S>: 'static + Send + Sync {

crates/storybook2/src/stories/kitchen_sink.rs 🔗

@@ -19,16 +19,20 @@ impl<S: 'static + Send + Sync + Clone> KitchenSinkStory<S> {
     }
 
     fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
-        let element_stories = ElementStory::iter().map(|selector| selector.story());
-        let component_stories = ComponentStory::iter().map(|selector| selector.story(cx)).collect::<Vec<_>>();
+        let element_stories = ElementStory::iter()
+            .map(|selector| selector.story())
+            .collect::<Vec<_>>();
+        let component_stories = ComponentStory::iter()
+            .map(|selector| selector.story(cx))
+            .collect::<Vec<_>>();
 
         Story::container(cx)
             .overflow_y_scroll(ScrollState::default())
             .child(Story::title(cx, "Kitchen Sink"))
             .child(Story::label(cx, "Elements"))
-            .child(div().flex().flex_col().children_any(element_stories))
+            .child(div().flex().flex_col().children(element_stories))
             .child(Story::label(cx, "Components"))
-            .child(div().flex().flex_col().children_any(component_stories))
+            .child(div().flex().flex_col().children(component_stories))
             // Add a bit of space at the bottom of the kitchen sink so elements
             // don't end up squished right up against the bottom of the screen.
             .child(div().p_4())

crates/ui2/src/children.rs 🔗

@@ -1,7 +0,0 @@
-use std::any::Any;
-
-use gpui3::{AnyElement, ViewContext};
-
-pub type HackyChildren<S> = fn(&mut ViewContext<S>, &dyn Any) -> Vec<AnyElement<S>>;
-
-pub type HackyChildrenPayload = Box<dyn Any + Send + Sync>;

crates/ui2/src/lib.rs 🔗

@@ -1,6 +1,5 @@
 #![allow(dead_code, unused_variables)]
 
-mod children;
 mod components;
 mod element_ext;
 mod elements;
@@ -8,7 +7,6 @@ pub mod prelude;
 mod static_data;
 mod theme;
 
-pub use children::*;
 pub use components::*;
 pub use element_ext::*;
 pub use elements::*;

crates/ui2/src/prelude.rs 🔗

@@ -3,7 +3,7 @@ pub use gpui3::{
     WindowContext,
 };
 
-pub use crate::{theme, ButtonVariant, ElementExt, HackyChildren, HackyChildrenPayload, Theme};
+pub use crate::{theme, ButtonVariant, ElementExt, Theme};
 
 use gpui3::{hsla, rems, rgb, AbsoluteLength, Hsla};
 use strum::EnumIter;