Skip to content

Commit

Permalink
Don't use extra parameter for ViewMarker, instead just use the super_…
Browse files Browse the repository at this point in the history
…bounds parameter directly
  • Loading branch information
Philipp-M committed Feb 15, 2024
1 parent fd66a4c commit 0a0efc8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions crates/xilem_core/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<T, A = ()>: $viewmarker + $($( $super_bounds )*)? {
pub trait $viewtrait<T, A = ()>: $($( $super_bounds )*)? {
/// Associated state for the view.
type State: $($( $state_bounds )*)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/xilem_web/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down
2 changes: 1 addition & 1 deletion src/view/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 0a0efc8

Please sign in to comment.