Change run_app(app: &mut A) to run_app(app: A) (#3721)
This allows the user more control over how they pass their application state to Winit, and will hopefully allow `Drop` implementations on the application handler to work in the future on all platforms.
This commit is contained in:
parent
d5fd8682eb
commit
bf97def398
17 changed files with 53 additions and 59 deletions
|
|
@ -28,11 +28,12 @@ impl EventLoop {
|
|||
Ok(EventLoop { elw })
|
||||
}
|
||||
|
||||
pub fn run_app<A: ApplicationHandler>(self, app: &mut A) -> ! {
|
||||
pub fn run_app<A: ApplicationHandler>(self, mut app: A) -> ! {
|
||||
let target = RootActiveEventLoop { p: self.elw.p.clone(), _marker: PhantomData };
|
||||
|
||||
// SAFETY: Don't use `move` to make sure we leak the `event_handler` and `target`.
|
||||
let handler: Box<dyn FnMut(Event)> = Box::new(|event| handle_event(app, &target, event));
|
||||
let handler: Box<dyn FnMut(Event)> =
|
||||
Box::new(|event| handle_event(&mut app, &target, event));
|
||||
|
||||
// SAFETY: The `transmute` is necessary because `run()` requires `'static`. This is safe
|
||||
// because this function will never return and all resources not cleaned up by the point we
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue