sotrh/learn-wgpu

Surface chapter code contains compilation errors!

Jatinchhabra21 opened this issue · 2 comments

I don't understand it fully but in new method of State implementation we are passing reference to a window but when instantiating a surface we are again passing a reference to window (which itself is a reference to window)? This causes compilation error cannot return value referencing local variable window.

Screenshot from 2024-05-20 00-51-55

async fn new(window: &'a Window) {}
instance.create_surface(&window)

Screenshot from 2024-05-20 00-53-54

Hello! Not sure if this issue is still relevant to you but I got arround this by simply removing the & from window, so the line is simply instance.create_surface(window);. I also didn't find the unsafe block to be necessary.

Hi Andrew! I did resolve the issue already, it was more of an FYI. I was not sure if it was intended for future chapters, so raised an issue here to get some thoughts.