From 3f9b651f33e57a7d90bd26d43fca3ec1a621db16 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Sun, 28 Jul 2024 22:58:28 +0200 Subject: [PATCH 1/2] xilem_web: Fix #459, and add `.boxed()` combinator --- xilem_web/src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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, From b14820cda063be0b8d7bfd7e05a8a45296ddb92a Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 29 Jul 2024 11:16:46 +0200 Subject: [PATCH 2/2] Remove unnecessary doc-comment line Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> --- xilem_web/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/xilem_web/src/lib.rs b/xilem_web/src/lib.rs index 307f01e28..cf4f5b567 100644 --- a/xilem_web/src/lib.rs +++ b/xilem_web/src/lib.rs @@ -106,7 +106,6 @@ pub trait DomView: /// # fn view() -> impl DomView { /// div("a label").boxed() /// # } - /// /// ``` fn boxed(self) -> Box> where