Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove hacky children
Marshall Bowersd320d3a8bfe7
diff --git a/crates/gpui3/src/element.rs b/crates/gpui3/src/element.rsindex 534be128dd1..ad4cfa97bc0 100644--- a/crates/gpui3/src/element.rs+++ b/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 {diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rsindex e0459098f57..83a773aa906 100644--- a/crates/storybook2/src/stories/kitchen_sink.rs+++ b/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())diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rsindex 36f7219eaa3..a1e6caf2754 100644--- a/crates/storybook2/src/storybook2.rs+++ b/crates/storybook2/src/storybook2.rs@@ -109,7 +109,7 @@ impl StoryWrapper {.flex().flex_col().size_full()- .child_any(self.selector.story(cx))+ .child(self.selector.story(cx))})}}diff --git a/crates/ui2/src/children.rs b/crates/ui2/src/children.rsdeleted file mode 100644index e9a55d1cc04..00000000000--- a/crates/ui2/src/children.rs+++ /dev/null@@ -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>;diff --git a/crates/ui2/src/lib.rs b/crates/ui2/src/lib.rsindex 1aa09cd1ced..51489173add 100644--- a/crates/ui2/src/lib.rs+++ b/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::*;diff --git a/crates/ui2/src/prelude.rs b/crates/ui2/src/prelude.rsindex 2d0342e765d..618ad4807be 100644--- a/crates/ui2/src/prelude.rs+++ b/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;