I want my function to be the event loop so I've make that:
pub fn windowEvent(self) -> (std::ops::FnMut(glutin::Event) -> ()){
return |event| {
match event {
glutin::Event::WindowEvent{ event, .. } => match event {
glutin::WindowEvent::CloseRequested => process::exit(0x0100),
glutin::WindowEvent::Resized(logical_size) => {
let dpi_factor = self.gl_window.get_hidpi_factor();
self.gl_window.resize(logical_size.to_physical(dpi_factor));
},
_ => ()
},
_ => ()
}
};
}
And in my loop
frame.events_loop.poll_events(frame.windowEvent());
But I have two errors:
error[E0277]: the trait bound `std::ops::FnMut(glutin::Event) + 'static: std::marker::Sized` is not satisfied --> src/window.rs:48:34 | 48 | pub fn windowEvent(self) -> (std::ops::FnMut(glutin::Event) -> ()){ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::FnMut(glutin::Event) + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `std::ops::FnMut(glutin::Event) + 'static` = note: the return type of a function must have a statically known size error[E0308]: mismatched types --> src/window.rs:49:16 | 49 | return |event| { | ________________^ 50 | | match event { 51 | | glutin::Event::WindowEvent{ event, .. } => match event { 52 | | glutin::WindowEvent::CloseRequested => process::exit(0x0100), ... | 60 | | } 61 | | }; | |_________^ expected trait std::ops::FnMut, found closure | = note: expected type `std::ops::FnMut(glutin::Event) + 'static` found type `[closure@src/window.rs:49:16: 61:10 self:_]`
If you can help me.
Sorry for my English because I'm french.