Hello there, I'm newbie in rust, I've just finished reading rust book. Now I'm trying to draw simple quad using wgpu-rs. I'm trying to make some abstractions over it, and there is how I'm creating a buffer:
When I try to compile this I get the error. I can't understand, why rust think, that parameter type will not live long enough. I've solved the problem by adding + 'static to where statement, but I don't understand - what exactly does it mean. In my little example I want to be sure, that data will live while Gapi lives, but I don't whant it to be static.
I can't comment on wgpu-rs specific stuff, but here's something I noticed:
This trait combined with this impl seems implausible to me. If create_vertex_buffer is meant to copy stuff out of data, as the T: Copy bound suggests, then there's no reason why the lifetime of data should be the same as the parameter of Gapi because you're not keeping the reference around after create_vertex_buffer. You might as well put the parameter on create_vertex_buffer itself: