crosspostato da: https://lemmy.world/post/1916287
Hi everybody, I’m new to Rust.
So, I have a struct
Panel
which contains a datawidget
which implements the traitWidget
I have to implement a function forPanel
that uses another function that requires a type that implementsWidget
.I tried
Box<T>
,Rc<T>
,Box<dyn Widget
,, but nothing, always compiler errors.
How can I fix this?
The first problem I saw is that
Widget::render
takesself
by value, meaning that the widget will be destroyed after being rendered once. The need to satisfy that method’s type could be the cause of the other errors you’re running into.