Here is my code:
struct AStruct {
S: String,
}
impl AStruct {
pub fn new() -> AStruct {
AStruct { S: "S".to_string() }
}
pub fn start(&'static mut self) {
self.S = "started".to_string();
yew::Callback::Callback(Rc::new(|result: Result<String, anyhow::Error>| {}));
}
}
fn main() {
let mut a: AStruct = AStruct::new();
a.start();
}
I think I need to keep the start
function parameter like this, but I get the following error:
error[E0597]: `a` does not live long enough
--> src/main.rs:17:5
|
17 | a.start();
| ^^^^^^^^^
| |
| borrowed value does not live long enough
| argument requires that `a` is borrowed for `'static`
18 | }
| - `a` dropped here while still borrowed
Is it possible to solve my problem without modifying start
?