-
Notifications
You must be signed in to change notification settings - Fork 921
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
Variant of Event::to_static
that takes self by reference
#1968
Comments
This is done by necessity, as you can't clone a mutable reference or any type which contains one. Nor can you turn any old mutable reference into one with the Previous efforts and discussions aimed at making things more ergonomic can be found in #1387 and #1456. |
If my understanding is correct |
Just confirming that this is an issue for me as well - I'm working with an existing codebase that converts the event to static and propagates that around, which is fine, except in the case where it can't be converted to static. Because if let Some(event) = event.to_static() {
app.handle_event(&event, control_flow);
} else {
// the event is dead here, there's nothing I can meaningfully do
} May I suggest renaming the current function to |
The current plan is to remove the lifetime entirely after #2900 is merged: #2973 (comment). |
Currently
Event::to_static
andWindowEvent::to_static
takes self by value. This is inconvenient because static variants of these enums are required to clone them. And so if one needs to clone these enums for any reason one also ends up needing to throw away theWindowEvent::ScaleFactorChanged
event.I propose instead to either change
to_static
to take a&self
or alternatively add an additional methodto_static_cloned
.The text was updated successfully, but these errors were encountered: