this post was submitted on 21 Jul 2023
3 points (80.0% liked)
Rust
6113 readers
8 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 2 years 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.I checked the code and noticed that I wrote
&self
as the parameter ๐คฆ๐ปNow everything works. Thanks man