-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use TypeId
to identify subscription::Map
#2237
Conversation
73ce77c
to
708665c
Compare
708665c
to
f39a5fd
Compare
I also had to add diff --git a/winit/src/application.rs b/winit/src/application.rs
index 9cd992f4..99c7a666 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -830,7 +830,7 @@ where
/// Updates an [`Application`] by feeding it the provided messages, spawning any
/// resulting [`Command`], and tracking its [`Subscription`].
-pub fn update<A: Application, C, E: Executor>(
+pub fn update<A: Application + 'static, C, E: Executor + 'static>(
application: &mut A,
compositor: &mut C,
surface: &mut C::Surface, to my local libcosmic tree for it to build. But with that compile fix things seems to work |
I assume using TypeId will change the semantics slightly, that will only update the subscription if the closure is changed in such a way that the type changes. If you change the closure in such a way that the type is still the same, the subscription will not be updated. So, if is desired to have this kind of functionality, maybe an explicit id like in the subscription::channel function is preferred. That would break the API though. So, not sure what is better, change the semantics or break API. |
Technically yes, but it should work as expected with function item types; which is the intended way to use the API here. It'd be great to be able to restrict the closure to function item types, but I don't think that's possible in Rust yet. |
In that case, I say, just document it and ship it :) |
This PR fixes #2236. The idea here is to use the
TypeId
of a closure instead of the hash of a function pointer insubscription::Map
, which I am assuming is more stable.Coincidentally, this also introduces closure support forSubscription::map
!