-
Notifications
You must be signed in to change notification settings - Fork 929
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
Platform specific traits and requests extensions #3474
Comments
Hm, after discussion in winit repo and However, for extensibility purposes the approach to use The actual mechanism for such a thing could look like: impl FancyBackendVTable {
fn set_foo_callback<T, F: Fn(&mut T) + 'static>(f:F) {
self.foo = |app| f(app.downcast_mut::<T>().unwrap());
}
} |
Unfortunately, the An example of such extensibility is show cased in rust-windowing/winit-next@05b8fd0 . The point why such thing is even needed, is to erase the |
I got it, makes sense. But yeah, does require the |
That's already the case for the The thing is that user state is only 1 or 1 doing a composition of other states, however the |
I figured how to do without generic, but with runtime check instead. So yeah, we can pick whatever we like more. Probably without generic is a bit more flexible. |
winit-extra
crate with platform specific traits and requests extensions
We generally could allow users to use the
downcast
API andIDETs
to use extra winit functionality without addingcfg
guards, they'll just have to cast before calling something, but if the cast will be always beNone
it'll be optimized out, so effectively the same as usingcfg
just your code is always compiling and it's easier to write cross platform code without testingall the features.
The text was updated successfully, but these errors were encountered: