From 0a0efc82e86bb6c738f0a30f5cbd5f323ce8b999 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 12 Feb 2024 01:34:41 +0100 Subject: [PATCH] Don't use extra parameter for ViewMarker, instead just use the super_bounds parameter directly --- crates/xilem_core/src/view/mod.rs | 8 +++----- crates/xilem_web/src/view.rs | 2 +- src/view/view.rs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/xilem_core/src/view/mod.rs b/crates/xilem_core/src/view/mod.rs index c6703bbe5..c3f687acc 100644 --- a/crates/xilem_core/src/view/mod.rs +++ b/crates/xilem_core/src/view/mod.rs @@ -9,18 +9,16 @@ mod memoize; /// Arguments are /// /// - `$viewtrait` - The name of the view trait we want to generate. -/// - `$viewmarker` - The name of the viewmarker trait as a workaround for Rust's orphan rules, -/// to allow views to be also viewsequences. /// - `$bound` - A bound on all element types that will be used. /// - `$cx` - The name of text context type that will be passed to the `build`/`rebuild` /// methods, and be responsible for managing element creation & deletion. /// - `$changeflags` - The type that reports down/up the tree. Can be used to avoid /// doing work when we can prove nothing needs doing. -/// - `$super_bounds` - (optional) parent traits to this trait (e.g. `Send + Sync`). +/// - `$super_bounds` - (optional) parent traits to this trait (e.g. `ViewMarker + Send + Sync`). /// - `$state_bounds` - (optional) trait bounds for the associated type `State` (e.g. `Send`). #[macro_export] macro_rules! generate_view_trait { - ($viewtrait:ident, $viewmarker:ident, $bound:ident, $cx:ty, $changeflags:ty; $(($($super_bounds:tt)*))? $(,($($state_bounds:tt)*))?) => { + ($viewtrait:ident, $bound:ident, $cx:ty, $changeflags:ty; $(($($super_bounds:tt)*))? $(,($($state_bounds:tt)*))?) => { /// A view object representing a node in the UI. /// /// This is a central trait for representing UI. An app will generate a tree of @@ -38,7 +36,7 @@ macro_rules! generate_view_trait { /// and also a type for actions which are passed up the tree in message /// propagation. During message handling, mutable access to the app state is /// given to view nodes, which in turn can expose it to callbacks. - pub trait $viewtrait: $viewmarker + $($( $super_bounds )*)? { + pub trait $viewtrait: $($( $super_bounds )*)? { /// Associated state for the view. type State: $($( $state_bounds )*)?; diff --git a/crates/xilem_web/src/view.rs b/crates/xilem_web/src/view.rs index 430ae9c56..95c64ec87 100644 --- a/crates/xilem_web/src/view.rs +++ b/crates/xilem_web/src/view.rs @@ -84,7 +84,7 @@ impl Pod { } } -xilem_core::generate_view_trait! {View, ViewMarker, DomNode, Cx, ChangeFlags;} +xilem_core::generate_view_trait! {View, DomNode, Cx, ChangeFlags; (ViewMarker)} xilem_core::generate_viewsequence_trait! {ViewSequence, View, ViewMarker, DomNode, Cx, ChangeFlags, Pod;} xilem_core::generate_anyview_trait! {AnyView, View, ViewMarker, Cx, ChangeFlags, AnyNode, BoxedView;} xilem_core::generate_memoize_view! {Memoize, MemoizeState, View, ViewMarker, Cx, ChangeFlags, static_view, memoize;} diff --git a/src/view/view.rs b/src/view/view.rs index ed0181f40..229ccdb17 100644 --- a/src/view/view.rs +++ b/src/view/view.rs @@ -23,7 +23,7 @@ use xilem_core::{Id, IdPath}; use crate::widget::{AnyWidget, ChangeFlags, Pod, Widget}; -xilem_core::generate_view_trait! {View, ViewMarker, Widget, Cx, ChangeFlags; (Send), (Send)} +xilem_core::generate_view_trait! {View, Widget, Cx, ChangeFlags; (ViewMarker + Send), (Send)} xilem_core::generate_viewsequence_trait! {ViewSequence, View, ViewMarker, Widget, Cx, ChangeFlags, Pod; : Send} xilem_core::generate_anyview_trait! {AnyView, View, ViewMarker, Cx, ChangeFlags, AnyWidget, BoxedView; + Send} xilem_core::generate_memoize_view! {Memoize, MemoizeState, View, ViewMarker, Cx, ChangeFlags, s, memoize; + Send}