diff --git a/xilem_web/src/lib.rs b/xilem_web/src/lib.rs index 70c8d5c45..307f01e28 100644 --- a/xilem_web/src/lib.rs +++ b/xilem_web/src/lib.rs @@ -88,7 +88,7 @@ where } /// A view which can have any [`DomView`] type, see [`AnyView`] for more details. -pub type AnyDomView = dyn AnyView; +pub type AnyDomView = dyn AnyView; /// The central [`View`] derived trait to represent DOM nodes in xilem_web, it's the base for all [`View`]s in xilem_web pub trait DomView: @@ -97,6 +97,26 @@ pub trait DomView: type DomNode: DomNode; type Props; + /// Returns a boxed type erased [`AnyDomView`] + /// + /// # Examples + /// ``` + /// use xilem_web::{elements::html::div, DomView}; + /// + /// # fn view() -> impl DomView { + /// div("a label").boxed() + /// # } + /// + /// ``` + fn boxed(self) -> Box> + where + State: 'static, + Action: 'static, + Self: Sized, + { + Box::new(self) + } + /// See [`adapt`](`core::adapt`) fn adapt( self,