struct App<'a> {
state: Option<State<'a>>,
window: Option<Window>,
}
impl<'a> ApplicationHandler for App<'a> {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let window = event_loop.create_window(Window::default_attributes()).unwrap();
self.window = Some(window);
self.state = if let Some(window) = &self.window {
let future_state = State::new(window);
let result = tokio::runtime::Runtime::new()
.unwrap()
.block_on(future_state);
Some(result)
} else { None };
}
}
How do I force that '1 outlives 'a?
impl<'a> ApplicationHandler for App<'a> {
| -- lifetime 'a
defined here
18 | fn resumed(&mut self, event_loop: &ActiveEventLoop) {
| - let's call the lifetime of this reference '1
...
22 | self.state = if let Some(window) = &self.window {
| ^^^^^^^^^^ assignment requires that '1
must outlive 'a