So, I have a struct Panel which contains a data widget which implements the trait Widget
I have to implement a function for Panel that uses another function that requires a type that implements Widget.
I tried Box<T>, Rc<T>, Box<dyn Widget, &T, but nothing, always compiler errors.
So the struct is something like
struct Panel<T: Widget> { data: T }
(tried also with Box, Rc, &mut T and Box<dyn Widget>
I need to implement a method for Panel which simply uses the function linked above. (so just asks for a Frame, the Rect type is generated by my other function)
That function takes ownership of the Widget, there's no borrowing here. Maybe that's the problem, that you're passing a reference instead of the actual object?
So, if you have a Panel containing the Widget, the function you're calling render_widget in has to take self, not &self or &mut self.
Alternatively, you can use data: Option<T> in Panel, let the function take &mut self and then use self.data.take() to move it out of self.