Remove state erasure for now

Nathan Sobo created

Change summary

crates/gpui3/src/elements.rs           |  2 -
crates/gpui3/src/elements/stateless.rs | 30 ----------------------------
crates/gpui3/src/window.rs             | 10 ---------
3 files changed, 42 deletions(-)

Detailed changes

crates/gpui3/src/elements.rs 🔗

@@ -3,7 +3,6 @@ mod hoverable;
 mod identified;
 mod img;
 mod pressable;
-mod stateless;
 mod svg;
 mod text;
 
@@ -12,6 +11,5 @@ pub use hoverable::*;
 pub use identified::*;
 pub use img::*;
 pub use pressable::*;
-pub use stateless::*;
 pub use svg::*;
 pub use text::*;

crates/gpui3/src/elements/stateless.rs 🔗

@@ -1,30 +0,0 @@
-use crate::{Bounds, Element, Pixels};
-use std::marker::PhantomData;
-
-pub struct Stateless<E: Element<State = ()>, S> {
-    element: E,
-    parent_state_type: PhantomData<S>,
-}
-
-impl<E: Element<State = ()>, S: Send + Sync + 'static> Element for Stateless<E, S> {
-    type State = S;
-    type FrameState = E::FrameState;
-
-    fn layout(
-        &mut self,
-        _: &mut Self::State,
-        cx: &mut crate::ViewContext<Self::State>,
-    ) -> anyhow::Result<(crate::LayoutId, Self::FrameState)> {
-        cx.erase_state(|cx| self.element.layout(&mut (), cx))
-    }
-
-    fn paint(
-        &mut self,
-        bounds: Bounds<Pixels>,
-        _: &mut Self::State,
-        frame_state: &mut Self::FrameState,
-        cx: &mut crate::ViewContext<Self::State>,
-    ) -> anyhow::Result<()> {
-        cx.erase_state(|cx| self.element.paint(bounds, &mut (), frame_state, cx))
-    }
-}

crates/gpui3/src/window.rs 🔗

@@ -926,16 +926,6 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {
             })
         });
     }
-
-    pub(crate) fn erase_state<R>(&mut self, f: impl FnOnce(&mut ViewContext<()>) -> R) -> R {
-        let entity_id = self.unit_entity.id;
-        let mut cx = ViewContext::mutable(
-            &mut *self.window_cx.app,
-            &mut *self.window_cx.window,
-            entity_id,
-        );
-        f(&mut cx)
-    }
 }
 
 impl<'a, 'w, S> Context for ViewContext<'a, 'w, S> {