use crate::Widget; pub struct Element { widget: Box>, } impl Element { pub fn new(widget: impl Descriptor + 'static) -> Self { Self { widget: Box::new(widget), } } } pub trait Descriptor { fn tag(&self) -> std::any::TypeId; fn build(&self) -> Box>; fn children(&self) -> &[Element]; fn clone(&self) -> Box>; } impl Clone for Box> { fn clone(&self) -> Self { self.as_ref().clone() } } impl Clone for Element { fn clone(&self) -> Self { Element { widget: self.widget.clone(), } } }