Hello!
In my little hobby project i want to add the cpal dependency. When i did, code closely interacting with the winit crate broke with a lifetime issue. I only added the dependency to my Cargo.toml, it isnt used anywhere in the Code. I don't understand why there would be any interaction. I linked the code below. To see the Error just uncomment the Cpal dependecy in Cargo.toml.
I use nightly-rust (need 1 feature) on apple silicon MacOs.
Hope you can help me!
edit: Here is the Error:
error[E0597]: `window` does not live long enough
--> src/visual/event_loop.rs:33:58
|
31 | let window = Window::new(&event_loop).unwrap();
| ------ binding `window` declared here
32 |
33 | let mut gpu_state = pollster::block_on(GPUState::new(&window));
| ---------------------------------^^^^^^^--
| | |
| | borrowed value does not live long enough
| argument requires that `window` is borrowed for `'static`
...
134 | }
| - `window` dropped here while still borrowed
error[E0597]: `window` does not live long enough
--> src/visual/event_loop.rs:43:18
|
31 | let window = Window::new(&event_loop).unwrap();
| ------ binding `window` declared here
...
43 | let window = &window;
| ^^^^^^^ borrowed value does not live long enough
44 | let _ = event_loop.run(move |event, elwt| match event {
| _____________-
45 | | Event::WindowEvent {
46 | | window_id: _, // can ignore because i only use one window
47 | | ref event,
... |
132 | | _ => {}
133 | | });
| |______- argument requires that `window` is borrowed for `'static`
134 | }
| - `window` dropped here while still borrowed
For more information about this error, try `rustc --explain E0597`.
warning: `RustRacker` (bin "RustRacker") generated 1 warning
error: could not compile `RustRacker` (bin "RustRacker") due to 2 previous errors; 1 warning emitted