From 0069dd5ce67981428d4ceae3b191b9083725a30b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 17 Nov 2023 20:05:37 -0700 Subject: [PATCH] WIP --- crates/gpui2/src/element.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs index b4b1af630e981a2170c9fa6b1cdd5a6857ff2349..26232620d9705c8745e43c4a5501c08edb775b14 100644 --- a/crates/gpui2/src/element.rs +++ b/crates/gpui2/src/element.rs @@ -5,7 +5,7 @@ use derive_more::{Deref, DerefMut}; pub(crate) use smallvec::SmallVec; use std::{any::Any, fmt::Debug, mem}; -pub trait Element { +pub trait Element: 'static + Sized { type ElementState: 'static; fn element_id(&self) -> Option; @@ -25,6 +25,10 @@ pub trait Element { cx: &mut ViewContext, ); + fn into_any(self) -> AnyElement { + AnyElement::new(self) + } + fn draw( self, origin: Point, @@ -34,7 +38,6 @@ pub trait Element { f: impl FnOnce(&Self::ElementState, &mut ViewContext) -> R, ) -> R where - Self: Sized, T: Clone + Default + Debug + Into, { let mut element = RenderedElement {