Hi ! I have an issue that I haven't been able to solve for a long time :
I have a Display
struct owning a peripheral instance. 2 fields of this struct are a Layer
struct which hold a reference to the peripheral instance.
However, when I instanciate the Display
this way
let disp = Display {
dma2d,
// ^^^ move occurs here
layer1: Layer::new(&dma2d),
// ^^^ reference moved value. But I can't write self.dma2d ...
layer2: Layer::new(&dma2d),
};
there is a problem because dma2d is moved into disp
but I try to give a ref to the layers.
Is there an elegant way to solve this, apart from a two stage construction with Option<Layer>
?
Thanks for your help !
PS : here is the playground code