i have the following problem:
error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
--> src/main.rs:109:25
|
109 | reload_list(&conn_clone, &content_clone, &combo_clone.active_id().unwrap().to_string())
| ^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'_` as defined on the body at 108:31...
--> src/main.rs:108:31
|
108 | combo.connect_changed(move |_| {
| ^^^^^^^^
note: ...so that closure can access `conn_clone`
--> src/main.rs:109:25
|
109 | reload_list(&conn_clone, &content_clone, &combo_clone.active_id().unwrap().to_string())
| ^^^^^^^^^^^
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> src/main.rs:109:25
|
109 | reload_list(&conn_clone, &content_clone, &combo_clone.active_id().unwrap().to_string())
| ^^^^^^^^^^^
...
The code is around:
...
fn main() -> Result<()> {
...
reload_list(&conn, &content, &combo.active_id().unwrap().to_string());
combo.connect_changed(move |_| {
reload_list(&conn_clone, &content_clone, &combo_clone.active_id().unwrap().to_string())
});
...
}
...
fn reload_list(conn: &'static Connection, content: &'static ListBox, list_id: &'static String) {
...
save_edit_button.connect_clicked(move |_| {
...
reload_list(&conn, &content, &list_id);
});
...
}
So how can I fix it, that this code will run. I had added 'static
to the reload_list
parameters, as the compiler said it, so this can be removed, but it comes: explicit lifetime required in the type of conn, content, list_id