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 {