-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require View: ViewMarker
to avoid the leaky abstraction/workaround fn view() -> impl View + ViewMarker
#162
Require View: ViewMarker
to avoid the leaky abstraction/workaround fn view() -> impl View + ViewMarker
#162
Conversation
Btw. I could for whatever reason not remove the requirement impl<T, A, V: View<T, A> + ViewMarker> ViewSequence<T, A> for V Does someone know why? Is this a bug in Rust? |
Answering my own comment (so I kinda think it's some form of bug in Rust), I think it's because |
One thing this change introduces though, is that types that implement I think this is ok, because I had some weird issues some time back in #141 (comment) So I doubt that it's generally a good idea to have a type that has manual implementations for |
f53ed72
to
9e1665d
Compare
…-> impl View + ViewMarker` Motivation: to avoid requiring `fn view() -> impl View + ViewMarker` and instead just using `fn view() -> impl View` I don't see a reason for types that implement `View`, but not `ViewMarker`. This requirement has the neat side-effect of avoiding weird error-messages otherwise, in case `impl ViewMarker for T` has been forgotten for `impl View for T`. The whole purpose AFAIK of `ViewMarker` is a workaround of the orphan rule, that something like this: ```rust impl<T, A, V: View<T, A> + ViewMarker> ViewSequence<T, A> for V ``` is possible. So I tried adding this as super trait requirement and it seems to be possible. I think this makes the leaky abstraction/workaround much more feasible as it's only required now for actual `View` implementations.
…bounds parameter directly
9e1665d
to
0a0efc8
Compare
I think this can be closed, as this targets I guess Xilem Web Core? |
Yes, when we don't ever want to return |
This PR adds the Requirement
View: ViewMarker
.Motivation: to avoid requiring
fn view() -> impl View + ViewMarker
and instead just usingfn view() -> impl View
I don't see a reason for types that implement
View
, but notViewMarker
. This requirement has the neat side-effect of avoiding weird error-messages otherwise, in caseimpl ViewMarker for T
has been forgotten forimpl View for T
.The whole purpose AFAIK of
ViewMarker
is a workaround of the orphan rule, that something like this:is possible.
So I tried adding this as super trait requirement and it seems to be possible.
I think this makes the leaky abstraction/workaround much more bearable as it's now only required for actual
View
implementations (AFAICS).