This commit is contained in:
Antonio Scandurra 2023-10-12 19:40:13 +02:00
parent ca35573ad5
commit 2044ccdc0b
4 changed files with 27 additions and 17 deletions

View file

@ -3,7 +3,8 @@ use std::fmt;
use std::sync::Arc;
use gpui3::{
BorrowAppContext, Bounds, Element, Hsla, LayoutId, Pixels, Result, ViewContext, WindowContext,
AnyElement, BorrowAppContext, Bounds, Element, Hsla, IntoAnyElement, LayoutId, Pixels, Result,
ViewContext, WindowContext,
};
use serde::{de::Visitor, Deserialize, Deserializer};
@ -146,6 +147,15 @@ pub struct Themed<E> {
pub(crate) child: E,
}
impl<E> IntoAnyElement<E::ViewState> for Themed<E>
where
E: Element,
{
fn into_any(self) -> AnyElement<E::ViewState> {
AnyElement::new(self)
}
}
impl<E: Element> Element for Themed<E> {
type ViewState = E::ViewState;
type ElementState = E::ElementState;