hello, rust beginner here, i have the following code and the compiler is complaining, i would say that i understand why is it doing so, but i don't quite know how to solve it, can i somehow move the ownership of the shader_module to the struct which i am trying to create and then reference it in the fragment_state? Or is there any other way? Thank you!
#Compiler is complaining
11 messages · Page 1 of 1 (latest)
fragment_state has a ref to shader_module, which is dropped at the end of the function
you need to separate the steps of 'create and return the shader module' from 'make a FragmentState that refers to it'
these cannot be in the same function
in my experience, a wgpu::FragmentState will fit nicely into constructing the containing RenderPipelineDescriptor
You could also store shader_module in Self
note that you can write a method on FragmentShader that returns the wgpu::FragmentState (which will then borrow from the FragmentShader)
yes, i am aware of this
so i should split it into two functions, something like new() and init(&self), new() will create struct with shader_module and in the init(&self) i can reference it while creating wgpu::FragmentState?