Help refactoring this line

source: learn-wgpu/ at master · sotrh/learn-wgpu · GitHub

I want to refactor this line: |event, _, control_flow| match event {


let t = move | ... | { ... }


So the problem here is I now need to specify the types for event, _, control_flow. What we get here is:

event: Event<_, T>
_: EventLoopWindowTarget<T>,
control_flow: &mut ControlFlow

The problem: I can't figure out what the generic parameter T is.


You could change the working code to |event: (), _, control_flow| and once you try to compile it it should give a error "expected () got Event<...>"

It's not clearly stated, but T is actually a type you get to pick; it's the type of “user events” which can wake the winit event loop from another thread. If you're not using that feature, the default is (), so you would want the parameter types Event<'_, ()>, EventLoopWindowTarget<()>.