this post was submitted on 21 Jul 2023
0 points (NaN% liked)
Rust
5938 readers
1 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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 takeself
, not&self
or&mut self
.Alternatively, you can use
data: Option<T>
in Panel, let the function take&mut self
and then useself.data.take()
to move it out of self.