I am using the iced graphics library, and upon updating the version of iced I'm using, I get a new error. The following code errors, and is immediately just added into my full ui component and then returned from the Application::view function:
let bottom_bar: Container<Message> = container(row()
.spacing(2)
.push_space(4)
.push(update_state)
.push_space(Length::Fill)
.push(col_slider_reset)
.push(col_slider)
.push(slider_text)
.push(toggle_style)
.height(Length::Units(20))
.align_items(Alignment::Center)
).style(style.settings_bar())
.align_y(Vertical::Center);
The error is as follows:
error[E0521]: borrowed data escapes outside of associated function
--> src\main.rs:953:46
|
895 | fn view<'a>(&'a self) -> Element<'a, Self::Message> {
| -- -------- `self` is a reference that is only valid in the associated function body
| |
| lifetime `'a` defined here
...
953 | let bottom_bar: Container<Message> = container(row()
| ______________________________________________^
954 | | .spacing(2)
955 | | .push_space(4)
956 | | .push(update_state)
... |
963 | | .align_items(Alignment::Center)
964 | | ).style(style.settings_bar())
| | ^
| | |
| |_________`self` escapes the associated function body here
| argument requires that `'a` must outlive `'static`
Looking at E0521 (https://doc.rust-lang.org/error-index.html#E0521), it seems to be an error about closures, and the fix shown is to remove a lifetime parameter from the closure, but my code isn't in a closure, and I can't remove the type from the function since its a function.
I also don't quite understand what it means that self escapes the function body, as this isn't a lifetime error I've seen/dealt with before.
Any ideas how to fix this error?